[英]How to set UITextfield position during device orientation
我在该图像视图上有一个图像视图,在此放置了两个textField。 当我将设备置于纵向模式时,UITextfield上的位置正确。 一旦我旋转了UITextfiled的设备位置,就更改了。 请帮助我。我正在使用IOS 6,谢谢。
尝试实现-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
。 旋转设备时将调用此方法。 在这里,您可以设置UITextField
的框架。
或者,您可以尝试设置AutoresizingMask。
有关自动布局的更多信息,请阅读此很棒的教程。 http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
在willAnimateRotationToInterfaceOrientation中为文本字段和图像设置框架
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
// set frame for your text field and image in landscape orientation.
}
else
{
// set frame for your text field and image in landscape orientation.
}
}
而已。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.