开发者

UINavigationController pushViewController - Keyboard lagging on Animation

I have a view controller that has a keyboard (I use becomFirstResponder in my viewDidLoad method to achieve this). This view controller also has a button which triggers an IBAction that uses 开发者_运维技巧pushviewcontroller to load another viewcontroller. This works fine but my problem is the keyboard seems to animate away after the content in the first view controller. So essentially it is still there when the next view controller loads for a few seconds and then slides out of the scene....Has anyone else encountered this problem?


In your view controller with the Text Fields hook up UITextFieldDelegate and do

myTextField.delegate = self;

then implement it in the controller -

// In Header
UITextField *currentField;

@property (nonatomic, retain) UITextField *currentField;

// In Implementation    
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    self.currentField = textField;
}

So when you are ready to push your new view controller you just -

[self.currentField resignFirstResponder];

or simpler yet resign all of your text fields


All you need to do is resign the keyboard, and fire an NSTimer which will call a method that will push to the next view controller after a fixed amount of time. You can play around with the time the NSTimer fires to get the effect you want. Hope that helps!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜