I have one image view on that image view i put two textField there. When i put device in portrait mode position on UITextfield is correct. Once i rotate my device position of UITextfiled change. Please help me.I am using IOS 6, Thanks in Advance.
There are many ways to implement it : 1. Constraints ( adjusting from xcode->editor->pin) 2. By pragmatically.
I personally suggest you to take a deep knowledge of this
Try to implement -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
. This method gets called when the device is rotated. Here you can set the frame of the UITextField
.
Alternatively you can try to set the AutoresizingMask.
for more about auto layout please read this awesome tutorial. http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
set frames for your text field and image in 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.
}
}
Thats It.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.