【问题标题】:UIMotionEffect not working when applied to view应用于视图时 UIMotionEffect 不起作用
【发布时间】: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


    【解决方案1】:

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

    【讨论】:

    • 您是否找到了一种以编程方式检测此问题的方法? (即其他然后明确检查 iPhone 4?)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-25
    • 1970-01-01
    • 2023-03-19
    • 2021-07-12
    • 2013-04-06
    • 1970-01-01
    相关资源
    最近更新 更多