I'm updating my iPhone app for the iPhone 5's larger screen, and there seems to be a problem with animateWithDuration:
. Before I turned on autolayout, the interface elements would move slightly up the screen when the UITextField became first responder, and would move down back to their original positions when the UITextField lost its first responder status. Now, they just haphazardly fly up and off the screen, and I have no idea why. I move the objects with the code below (and this worked with autolayout turned off):
[UIView animateWithDuration:.25 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
int offset = 160;
[object1 setFrame:CGRectMake(0, -offset, object1.frame.size.width, object1.frame.size.height)];
[object2 setFrame:CGRectMake(object2.frame.origin.x, object2.frame.origin.y-offset, object2.frame.size.width, object2.frame.size.height)];
[object3 setFrame:CGRectMake(object3.frame.origin.x, object3.frame.origin.y-offset, object3.frame.size.width, object3.frame.size.height)];
}
completion:^(BOOL finished){}];
Does it have something to do with trying to move the objects by a constant? Even when I set offset
to 0
, all the objects still fly off the screen. I've tried detecting which screen the device has and moving the objects by different amounts, but that hasn't worked either. Does anybody have any ideas?
Thanks in advance!