Some pitfalls of iOS horizontal and vertical screen switching (continuous update), ios Switching

Source: Internet
Author: User

Some pitfalls of iOS horizontal and vertical screen switching (continuous update), ios Switching

Recently, I was working on a video App and encountered a video rolling playback problem, followed by the problem of horizontal and vertical screens. I was so naive that I didn't want to configure the screen. I just want to rotate the video View, but I want to share something including AlertView or portrait screen style. It is enough to submit the project once every week... People are tired of reviewing it.) It has never been changed. It was just yesterday that the change was a deep hole!

Because the homepage is a scrolling playback, I don't want to adapt to the landscape screen, and I have to modify the coordinates to determine what to do. I have read the mainstream apps, and Sohu looks like it is the best. Effect

(I just caught it for half a day. I don't even know that the camera has a feature called slow motion)

The tableView behind them does not move when the screen is turned. At the beginning, they simply thought it was just a turn of the view, but it was still a vertical screen... However

Then I decided what the network was about. I suddenly found that I couldn't pull this panel! You can only pull the wood

After the screen is pulled out, the screen is displayed !!!

So they thought that they should change the interface direction. Then I thought, the tableview will not move, so I will manually change the interface direction and then switch to the video View.

Before ios8, manually call

UIApplication *application=[UIApplication sharedApplication];[application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];

 

You can select the interface direction. For more information about the interface direction and the device direction, see screen rotation notes of maple leaf.

However, I did not respond after calling it in my code. I found it in my base class Viewcontroller.

- (BOOL)shouldAutorotate{   return YES;}

Okay. NO is returned in the display video window.

- (BOOL)shouldAutorotate{    return NO;}

I found that statusbar turned over and the view was not moved. This time, I pulled down the Panel and got everything right. The Alertview popped up is in the correct direction.

Even the keyboard direction is correct. Okay, the problem seems to have been solved. When the video is full screen, set the statusbar direction and switch the video form to OK.

Then I went to bed happily.

The next day .. I changed my mind and found that there was no problem. I just needed to control the View Size and rotation. It seems that this is the end, but it is actually very simple...

However, after iOS8 came out, it seemed that the UIScreen bounds would rotate in the direction of the interface, and the bounds would change and affect it. Then I ran it again using the simulator, and there was a problem.

The width and height seem to be reversed, and ios8! Fortunately, I remember that the bonuns of UIScreen under Mao iOS8 has changed.

Originally under iOS8

UIScreen is now interface oriented:

  • [UIScreen bounds] now interface-oriented
  • [UIScreen applicationFrame] now interface-oriented
  • Status bar frame configurications are interface-oriented
  • Keyboard frame configurications are interface-oriented

Well, I can judge it, so

CGFloat max = MAX(SCREEN_HEIGHT, SCREEN_WIDTH);CGFloat min = MIN(SCREEN_HEIGHT, SCREEN_WIDTH); _player.view.frame = CGRectMake(0, 0, min, max);

Run again. OK, full screen. Well, it seems that all the traps have been filled out, and the performance is good. I will add a chicken leg to myself at noon today.

Related Article

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.