简体   繁体   中英

animated UIView in portrait mode is not consistent in landscape on ios

i am developing an application using autolayout in ios 7. i am moving a label from the top to the middle of the view controller using [UIView commitAnimation] in the portrait mode. the label moves to the middle of the screen. When i change the device orientation to landscape after animation is over, the label again moves back to the top instead of in the middle of the screen.

how to maintain the animation in both portrait and landscape mode ?

When using autolayout viewDidLayoutSubviews gets called everytime when UI changes. This gets called when your device is rotated from portrait to landscape and sets the position of the label again to the previous. Assuming you have designed your layout with IB. You have to change the position of the label accordingly in viewDidLayoutSubviews than it will work perfectly as expected.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM