當textView
顯示或隱藏鍵盤時,我正在使用波紋管代碼向上或向下移動屏幕,通過這種方式,我可以在聚焦時看到最後一個字段。顯示鍵盤時不顯示導航欄
- (void)textViewDidBeginEditing:(UITextView *)textField
{
[self animateTextView: textField up: YES];
}
- (void)textViewDidEndEditing:(UITextView *)textField
{
[self animateTextView: textField up: NO];
}
- (void) animateTextView: (UITextView*) textField up: (BOOL) up
{
const int movementDistance = 130; // tweak as needed
const float movementDuration = 0.2f; // tweak as needed
int movement = (up ? -movementDistance : movementDistance);
[UIView beginAnimations: @"anim" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.view.frame, 0, movement);
[UIView commitAnimations];
}
但問題是,navBar
它也是移動時屏幕向上移動,在那裏所有的移動除了navBar
或保持navBar
在它的使用[self animateTextView: textField up: YES];
後位置的方法嗎?
爲什麼?你爲什麼要這樣設計你的觀點?爲什麼不使用'UINavigationController'?你爲什麼使用'beginAnimations:'API?這是什麼,iOS/iPhoneOS 3? –