Reputation: 109
is it possible to disable orientation rotating during textField editing? For example, it's possible to rotate app between portrait and landscape, but if you tap a text field in portrait, you can't rotate to landscape until your done editing? or vice versa if your in landscape?
I'm thinking if there is a way to do this, I'd be implementing it in textFieldDidBeginEditing and textFieldDidEndEditing
any help would be appreciated, thank you
Upvotes: 0
Views: 196
Reputation: 8502
Set your textField delegate to be the view controller. When the textfield lets you know it's going to edit (I believe it's something like - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
) set an iVar to your current orientation (_orientation = self.interfaceOrientation) and set a BOOL iVar(I'd call it _editing) to YES. In the method - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
return NO if it's not the orientation of the iVar and _editing is YES.
Upvotes: 1