iOS新手在这里,但经过一些谷歌搜索和教程看我似乎无法弄清楚我搞砸了哪里.我将尝试提供尽可能多的信息,我已经在我的UIViewController子类(根控制器)中为UIMotionEffect编写了一些代码.我的故事板包含一个UIViewcontroller子类(下面),其中包含一个UIImageView,它是代码中的IBOutlet.一切都运行,我的调试器点击viewDidLoad:方法,但移动我的手机根本不移动图像.任何帮助,将不胜感激!谢谢阅读.
- (void)viewDidLoad { [super viewDidLoad]; CGFloat leftRightMin = -55.0f; CGFloat leftRightMax = 55.0f; UIInterpolatingMotionEffect *leftRight = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis]; leftRight.minimumRelativeValue = @(leftRightMin); leftRight.maximumRelativeValue = @(leftRightMax); UIMotionEffectGroup *moGroup = [[UIMotionEffectGroup alloc] init]; moGroup.motionEffects = @[leftRight]; [bgImageView addMotionEffect:moGroup]; }
在我的同一个类的头文件中...
@interface TabletMenuViewController : UIViewController @property (weak, nonatomic) IBOutlet UIImageView *bgImageView; @end
Ahah,根据发行说明,iPhone 4上没有视差和其他类似功能.看起来我的开发电话太旧而且被破坏了.