开发者

iPhoneSDK: Weird bug after pushing a detailviewcontroller while the keyboard is still open

I have a very weird bug here, this is the scenario;

-I click on one of the textfields on my UITableView, uikeyboard appears,

-Then without pressing done, I click another textfield on screen(a disabled one),

-This disabled textfield pushes a detailview controller,

-I do my job on the detailview and return back,

-S开发者_运维知识库urprize! the main UITableview is no more scrollable to bottom anymore! so I can not edit the bottom cells anymore!

This does not happen IF I press done after editing(so close the keyboard) and then click the detail view, now it works good.

I think it is something about resignfirstResponder is not called before I switch to another view, so I tried to send this msg to all the textfields in the tableview..but it got worse.

I tried also adding this line below just before I push the detailviewcontroller, but not worked, this is interssting cause this is what I call to resign the number pad normally, and it works when it is called from my custom "done" button to dismiss the nuber pad

[[self view] endEditing:YES];

And this is how I set the uikeyboards depend on the content in cellforRowAtIndex method

    if(somelogic){      
    cell.textField.keyboardType=UIKeyboardTypeNumberPad;                
    [self resignFirstResponder];        
    [self becomeFirstResponder];        
}

else{       
    cell.textField.keyboardType=UIKeyboardTypeDefault;
    [self resignFirstResponder];        
    [self becomeFirstResponder];        
}

Any Ideas?


Just call [currentTextField resignFirstResponder] before you push the detail view controller.

Set the currentTextField in the following method.

- (void)textFieldDidBeginEditing:(UITextField *)textField {

    currentTextField = textField;
    // Your code here 
}


Occam's razor. Don't let them not click the done button.

Put a transparent UIButton accross the entire screen. Show it when you call [textField becomeFirstResponder]. You can either prevent people from touching the screen and switching textFields, or call [textField resignFirstResponder] when it is tapped.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜