I have two textfields in a subview as viewLogin. when try to enter text key board is hiding them. I solved that problem by moving the viewLogin.
Code is…
- (void)textFieldDidBeginEditing:(UITextField *)textField {
UIDeviceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) {
viewLogin.frame = CGRectMake((1024-viewLogin.frame.size.width)/2, (768-viewLogin.frame.size.height)/9, viewLogin.frame.size.width, viewLogin.frame.size.height);
}
else {
viewLogin.frame = CGRectMake((768-viewLogin.frame.size.width)/2, (1024-viewLogin.frame.size.height)/2, viewLogin.frame.size.width, viewLogin.frame.size.height);
}
}
- (void)textFieldDidEndEditing:(UITextField *)textField {
UIDeviceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) {
viewLogin.frame = CGRectMake((1024-viewLogin.frame.size.width)/2, (768-viewLogin.frame.size.height)/2.5, viewLogin.frame.size.width, viewLogin.frame.size.height);
}
else {
viewLogin.frame = CGRectMake((768-viewLogin.frame.size.width)/2, (1024-viewLogin.frame.size.height)/2, viewLogin.frame.size.width, viewLogin.frame.size.height);
}
}
Problem here i facing is if i first change the orientation to Landscape and click on textField its working fine but if i first click on textField in portrait mode and then changed to Landscape left/right its not working..
can some help me to solve this….
Thanks in advance
This is what Apple uses (take a look at the KeyboardAccessory example): First, register for keyboard notifications in
viewDidLoadand make sure you unregister in
viewDidUnloadthen add these methods to your implementation:
I’m using it and I do not have any problems with orientation changes.