Change or disable the iPhone rotating animation when orientation changes

后端 未结 3 616
渐次进展
渐次进展 2021-02-06 06:10

How do I change or disable the rotating animation when screen orientation changes from landscape to portrait, or vice versa?

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-06 07:04

    The answer by @Nils Munch above is find for < iOS7. For iOS 7 or later you can use:

    - (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator {
        [UIView setAnimationsEnabled:NO];
    
        [coordinator notifyWhenInteractionEndsUsingBlock:^(id context) {
            [UIView setAnimationsEnabled:YES];
        }];
    
        [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
    }
    

提交回复
热议问题