繁体   English   中英

UIView animateWithDuration…在iOS 8中不起作用

[英]UIView animateWithDuration… not working in iOS 8

尝试在键盘启动时为按钮设置动画时,[UIView animationWithDuration]出现问题。 我有一个通知告诉我键盘何时启动,然后ViewController在视图中调用此方法。 该按钮会设置动画,但显示不正确。 它只是从屏幕上的随机位置到先前的位置设置动画。 我再次提出此问题的原因是,我从其他帖子中看到了答案,即在ViewController中将视图的translationsAutoresizingMaskIntoConstraints属性设置为YES可以解决问题,但不能解决问题。

    [self.view setTranslatesAutoresizingMaskIntoConstraints:YES];

动画如下:

- (void)animateForKeyboardAppearanceWithKeyboardSize:(CGSize)keyboardSize; {
    [UIView animateWithDuration:0.3f
                 animations:^{
                     [self.sendSMSButton setFrame:CGRectMake(0,
                                                             self.frame.size.height - keyboardSize.height - self.sendSMSButton.frame.size.height,
                                                             self.frame.size.width,
                                                             self.sendSMSButton.frame.size.height)];
                 }];
}

有人知道发生了什么吗? 提前致谢。

您是否确保不会重复调用此方法? 也可以尝试对按钮进行子类化,覆盖-setFrame并仔细检查以查看是否在设置动画效果时其他设置了按钮的框架。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM