我不知道爲什麼會發生這種情況..這段代碼有什麼問題..(動畫視圖)?
我想在用戶開始在文本字段中鍵入內容時激活我的視圖。但代碼僅適用於橫向左排列,但不正確的景觀...
這些方法被稱爲在兩個方向...
這裏是代碼..
- (void)keyboardWasShown:(NSNotification *)aNotification {
if (keyboardShown)
return;
NSTimeInterval animationDuration = 0.3;
CGRect frame = self.view.frame;
frame.size.width += 150;
[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
[UIView setAnimationDuration:animationDuration];
self.view.frame = frame;
[UIView commitAnimations];
keyboardShown = YES;
}
- (void)keyboardWasHidden:(NSNotification *)aNotification {
NSTimeInterval animationDuration = 0.3;
CGRect frame = self.view.frame;
frame.size.width -= 150;
[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
[UIView setAnimationDuration:animationDuration];
self.view.frame = frame;
[UIView commitAnimations];
keyboardShown = NO;
}
截至目前我剛硬編碼的值..
有你回來是 - 「(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation」?或者這是你添加到窗口的根視圖控制器? –
你爲什麼要調整寬度而不是高度? – gschandler
是的,你應該調整高度...... –