2013-04-28 47 views
0

我設置的位置,我UITextFieldUIKeyboardWillHideNotification是像這樣的UITextField的setText復位位置

[chatTextField setFrame:CGRectMake(chatTextField.frame.origin.x, chatTextField.frame.origin.y - 250, chatTextField.frame.size.width, chatTextField.frame.size.height)]; 
解僱

enter image description here

然而,當我再打電話

[chatTextField setText: @""]; 

enter image description here

位置的UITextField被設置回開始位置(在鍵盤下)。這也發生在UIWebView同樣的看法。
爲什麼重置職位?我是否以不正確的方式設置了框架位置?

+0

使用兩種UIKeyboardDidShowNotification和UIKeyboardWillHideNotification,不只是一個,檢測鍵盤存在。 – 2013-04-28 19:56:51

回答

0

您設置框架正確。您需要提供您的問題更多的代碼...

+0

我正在調用[chatTextField setText:@「」],當使用textFieldShouldReturn按下返回時,導致視圖重置。除此之外,它的代碼真的很少。 – 2013-04-28 19:52:28

0

如果使用

- (BOOL)textFieldShouldReturn:(UITextField *)textField 
{ 
     [chatTextField setText: @""]; 

return NO; 
} 

你需要返回NO

+0

謝謝,我已將其更改爲否。然而,這並沒有解決這個問題,兩個組件的位置仍然重置。註釋掉[chatTextField setText:@「」];阻止這種情況發生。我也想注意隱藏鍵盤使它們恢復正常,這實際上他們應該保持不變。 – 2013-04-28 19:59:39