我會調整UITableView
的大小並向上滑動UIView
,其中包含UITextField
這個字段被觸發。這是兩個簡單的原型:當UITextField被觸發時,同步向上滑動UIView並調整UITableView的大小
現在我有這樣的代碼:
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.3];
[UIView setAnimationBeginsFromCurrentState:YES];
[myView setFrame:CGRectMake(myView.frame.origin.x, myView.frame.origin.y - 167, myView.frame.size.width, myView.frame.size.height)]; // 216 (keyboard's height) - 49 (tabbar's height) = 167
[UIView commitAnimations];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.3];
[UIView setAnimationBeginsFromCurrentState:YES];
[myView setFrame:CGRectMake(myView.frame.origin.x, myView.frame.origin.y + 167, myView.frame.size.width, myView.frame.size.height)];
[UIView commitAnimations];
return TRUE;
}
的問題是,在鍵盤滑動畫和myView
滑動畫是不同步的。如何使這兩個動畫完美同步?
如何在鍵盤可見時調整UITableView
的大小,並在鍵盤將隱藏時返回原始高度?
[在成爲FirstFirstResponder或resignFirstResponder的情況下將對象保留在鍵盤上?](http://stackoverflow.com/questions/8704137/keeping-object-on-top-of-keyboard-in-the -event-of-become -firstfirstresponder-or-resign) – 2012-02-05 19:25:29
如何使用UIView作爲tableFooterView在底部顯示。如果現在所有這些都被包裝到UITableViewController中,您可以免費獲得所需的功能。 – Till 2012-02-05 19:55:13
@提示否,因爲我想讓UIView始終可見。 – 2012-02-05 20:35:21