我在子视图中有两个文本字段作为 viewLogin。当尝试输入文本时,键盘隐藏了它们。我通过移动 viewLogin 解决了这个问题。代码是...
- (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);
}
}
我面临的问题是,如果我首先将方向更改为横向并单击 textField 它工作正常但是如果我首先在纵向模式下单击 textField 然后更改为横向左/右它不起作用..
有人可以帮我解决这个问题....
提前致谢