簡體   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