iphone - UIMotionEffect 在应用于 View 时不起作用

标签 iphone objective-c uiviewcontroller ios7

这里是 iOS 新手,但经过一些谷歌搜索和观看教程后,我似乎无法弄清楚我哪里搞砸了。我将尝试提供尽可能多的信息,我已经在 UIViewController 子类(根 Controller )中为 UIMotionEffect 编写了一些代码。我的 Storyboard包含一个 UIViewcontroller 子类(如下),其 View 包含一个 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

storyboard enter image description here enter image description here

最佳答案

啊哈,根据发行说明,视差和其他一些类似功能在 iPhone 4 上不可用。看来我的开发手机太旧了,而且坏了。

关于iphone - UIMotionEffect 在应用于 View 时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20820703/

相关文章:

ios - 关闭 SKScene 后,内存仍然很高

ios - viewDidAppear : called when using presentViewController:animated:completion:

ios - 如何在自定义容器 View Controller 中实现交互式转换

iphone - 我可以使 UINavigationController 仅在第二级加载,而不是在 Root View Controller 加载

iphone - iOS获取当前地址名称-mkplacemark?

iphone - 如何在cocos2d-iphone中的CCLayer或CCScene中添加UITextView

ios - 我可以使用哪些工具来制作 iPhone 应用截屏视频?

ios - UIButton 横跨 UIPageViewController 的所有页面

ios - 节与其标题之间的 UITableView 空间

iphone - 实例化其他 View Controller 时出错