測試我的應用程序在iOS 11測試版7 - 它似乎像鍵盤不推高內容如果我的UIViewController。UIKeyboardWillShowNotification問題與ios 11測試版7
的代碼看起來是這樣的(因爲iOS7工作):
- (void)handleNotification:(NSNotification*)notification {
if (notification.name == UIKeyboardWillShowNotification) {
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
nextButtonALBottomDistance.constant = keyboardSize.height + initialPhoneBottomDistance;
codeBottomViewALBottomDistance.constant = keyboardSize.height + initialCodeBottomDistance;
double animationDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:animationDuration animations:^{
[self.view layoutIfNeeded];
}];
}
else if (notification.name == UIKeyboardWillHideNotification) {
nextButtonALBottomDistance.constant = initialPhoneBottomDistance;
codeBottomViewALBottomDistance.constant = initialCodeBottomDistance;
double animationDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:animationDuration animations:^{
[self.view layoutIfNeeded];
}];
}
}
足夠有趣 - 當我按下home鍵(最小化的應用程序),並重新打開它(沒有殺死它) - 佈局是固定的。
它看起來像一個iOS 11測試版的bug,但到目前爲止我還找不到任何參考。
很高興知道別人是否有這個問題。
用'UIKeyboardframeenduserinfokey'替換'UIKeyboardFrameBeginUserInfoKey' –
好像在工作!非常感謝@AdityaSrivastava! – Gil
很高興爲您效勞 –