IPhone DevelopmentSet rotation in Message notification mode in the ApplicationViewIs the content to be introduced in this article, mainly to learn how to rotateView. For details, refer to this article. I saw this article. I directly reproduced it. There is nothing to explain. I will understand it at a Glance :).
The entire program needs to support switching between landscape and landscape screens, which is relatively simple.
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
In the method, return YES.
But what if I only want a VC (= View Controller) to support horizontal and vertical screen switching? In that view controller alone, it is ineffective to do the same as above.
In this case, we can determine the Orientation of the UIDevice:
1. register the uideviceorientationdidchangenoication ication notification of UIDevice in VC:
- NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
- [center addObserver:self selector:@selector(doRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
2. Process in your own doRotate function:
- - (void)doRotate:(NSNotification *)notification{
- UIDevice *myDevice = [UIDevice currentDevice];
- UIDeviceOrientation deviceOrientation = [myDevice orientation];
- UIApplication *app = [UIApplication sharedApplication];
- [app setStatusBarOrientation:deviceOrientation];
- }
3.
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
Return YES.
Summary:IPhone DevelopmentSet rotation in Message notification mode in the ApplicationViewI hope this article will help you!