Ios UITextField setText重置位置
我正在设置我的Ios UITextField setText重置位置,ios,objective-c,Ios,Objective C,我正在设置我的UITextField的位置,这时UIKeyboardWillHideNotification像这样被触发 [chatTextField setFrame:CGRectMake(chatTextField.frame.origin.x, chatTextField.frame.origin.y - 250, chatTextField.frame.size.width, chatTextField.frame.size.height)]; 但是当我再打电话的时候 [chatTe
UITextField
的位置,这时UIKeyboardWillHideNotification
像这样被触发
[chatTextField setFrame:CGRectMake(chatTextField.frame.origin.x, chatTextField.frame.origin.y - 250, chatTextField.frame.size.width, chatTextField.frame.size.height)];
但是当我再打电话的时候
[chatTextField setText: @""];
UITextField
的位置被设置回开始时的位置(在键盘下)。同样在同一视图上的UIWebView也会发生这种情况。
为什么要重新设置位置?是否以错误的方式设置帧位置?您将帧设置为正确的。您需要提供更多的问题代码 如果您使用
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[chatTextField setText: @""];
return NO;
}
您需要返回否当使用textfield shouldlreturn按下return键时,我正在调用[chatterxtfield setText:@”“],这就是导致视图重置的原因。除此之外,它实际上只有很少的代码可显示。使用UIKeyboardDidShowNotification和UIKeyboardWillHideNotification(而不仅仅是一个)来检测键盘的存在。谢谢,我已将其更改为“否”。但这并没有解决这一问题,两个组件的位置仍在重置。注释掉[chatterxtfield setText:@”“;阻止这种情况发生。我还想指出的是,隐藏键盘会使它们恢复正常,实际上它们应该保持不变。