How to Set rotation View in Message notification mode in iPhone development applications

Source: Internet
Author: User

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.

 
 
  1. - (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:

 
 
  1. NSNotificationCenter *center = [NSNotificationCenter defaultCenter];  
  2. [center addObserver:self selector:@selector(doRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; 

2. Process in your own doRotate function:

 
 
  1. - (void)doRotate:(NSNotification *)notification{  
  2. UIDevice *myDevice = [UIDevice currentDevice];  
  3. UIDeviceOrientation deviceOrientation = [myDevice orientation];  
  4. UIApplication *app = [UIApplication sharedApplication];  
  5. [app setStatusBarOrientation:deviceOrientation];  

3.

 
 
  1. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 

Return YES.

Summary:IPhone DevelopmentSet rotation in Message notification mode in the ApplicationViewI hope this article will help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.