开发者

textFieldShouldReturn is not working in ipad

开发者 https://www.devze.com 2023-03-23 18:21 出处:网络
I am creating an application on IPad. I use a text field with default return key to write message.After writing a message I press return key..Then the keyboard dissappeared, but the method- (BOOL)text

I am creating an application on IPad. I use a text field with default return key to write message.After writing a message I press return key..Then the keyboard dissappeared, but the method - (BOOL)textFieldShouldReturn:(UITextField *)textField {} does NOT get called. I have some code within the textFieldShouldReturn function...

- (BOOL)textFieldShouldReturn:(UITextField *)textField {

[textField resignFirstResponder];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];  
if(cPageNavType == CUTSOM_NAV_BAR){
    mToolbar.frame = CGRectMake(0, 438, 320, 44);
    mTableView.frame = CGRectMake(0, 40, 340, 400); 
}else {
    mTableView.frame = CGRectMake(0, 0, 340, 480-44-18-28);
    mToolbar.frame = CGRectMake(0, 480-44-18-28, 320, 44);
}
[UIView commitAnimations];

//[self postMessag开发者_如何学Goe:nil];
return YES;
}

so what can I do? Thanks in advance


Things to check

  1. Add <UITextFieldDelegate> ,make your class receiver of delegate
  2. OfCourse add delegate method(put break points)
  3. Connect the textfield outlets (delegates and referencing outlets if any)
0

精彩评论

暂无评论...
验证码 换一张
取 消