【发布时间】:2013-12-29 00:00:31
【问题描述】:
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
【问题讨论】:
标签: iphone objective-c uiviewcontroller ios7