【问题标题】:View doesn't move up on iPhone 5 with iOS 7.1在装有 iOS 7.1 的 iPhone 5 上,视图不会向上移动
【发布时间】:2015-02-05 12:20:18
【问题描述】:

我使用此代码将视图向上移动并在键盘出现时更改其颜色。

CGRect newFrame = CGRectMake(0, -self.bgImageView.frame.size.height + [UIApplication sharedApplication].statusBarFrame.size.height*1.4 self.width, self.height);
[UIView animateWithDuration:0.25 animations:^{
    [self.view setFrame:newFrame];
    self.overlay.backgroundColor = [UIColor clearColor];
}];

它适用于所有运行 iOS 7.1 和 iOS 8 的 iPhone 模拟器,但运行 iOS 7 的 iPhone 5 除外。颜色会发生变化,但视图不会向上移动。

【问题讨论】:

  • 注意:不要在块内使用 self ,因为它可能会导致保留循环。例如:__weak __typeof__(self) weakSelf = self; dispatch_group_async(_operationsGroup, _operationsQueue, ^ { [weakSelf doSomething]; } );

标签: ios objective-c iphone xcode animation


【解决方案1】:

尝试强制UIView 启用它以使动画正常工作:

[UIView setAnimationsEnabled:YES];

【讨论】:

    猜你喜欢
    • 2014-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-20
    • 1970-01-01
    • 2017-01-14
    • 2018-08-20
    • 1970-01-01
    相关资源
    最近更新 更多