Explain how to solve the app's IOS 7 top status bar fit problem _ios

Source: Internet
Author: User

First of all, in iOS7, because the status bar no longer occupies a separate 20px, if the app needs to support both iOS7 and ios6.1 below, it needs to be adapted to start with:
First look at the results of the IOS7 and IOS6 after the new project with Xcode:
PS: A empty application inside + a rootcontroller, as the window root controller, view inside put a tableview;


is not encountered IOS7 new problems, the status bar and TableView overlap, OK, see this do not want to see the results, below we begin to formally solve this recruit not like the effect.
The first step: do not check the use AutoLayout in Xib, as shown in the following figure:

The second step: The second step: Choose View as "ios6.1 and earlier", or the position of the above figure;
Step three: In size inspector, there is a IOS6/7 deltas: represents the increment of posx, increment of posy, width increment, height increment respectively.

PS: In "ios6.1 and earlier" mode, because the status bar has a height of 20, when the app runs in ios7.0 mode, it needs to move 20 pixels down, so it's set to 20 on Δy.
The TableView coordinates move down 20, because the height of the entire screen is constant, so in the ios7.0 and later mode, you need to subtract the tableview height by 20 pixels, in ios6.1 and earlier mode, Set the TableView δheight to 20. If you do not set the bottom of the Δheight,tableview will have 20 pixels is not visible, you can test the demo to see.
Note ***:δ, positive number indicates increase, negative number indicates minus.
Fourth step: OK, Setup complete, to look at the effect on iOS:

is not the magical discovery and the former has the familiar hurrying feet ... This allows the "ios6.1 and earlier" and "ios7.0 and later" UI layouts to be unified.

Another way
the above through the Xib settings to achieve the status bar and view overlap problem, next we talk about the network to modify the window frame method.
First steps:
First: Add the following code inside the Appdeletage:

  if ([[[[[[Uidevice Currentdevice] systemversion] floatvalue] >= 7.0) {
  self.window.frame = CGRectMake (0.0f,20.0f, self.window.frame.size.width,self.window.frame.size.height-20.0f);
  }

2. Attribute in Info.plist file: View controller-based status bar appearance value set to No.
Look at the effect below:

Looking at the picture below, you will find a problem:

What is the cause of this? I found out that since window you turned 548 to 528, you found that the height of the tableview was still 548, resulting in 20 pixels that could not be displayed. That some students will say, directly changed to 528 don't get it, yes, can be changed, you found IOS7 did not have the problem of missing pixels, but in IOS6 there is a direct shortage of half, look at the following figure:

So, I'm testing it myself, and it's a little tricky to fit IOS7 and IOS6.
Finally, explain the role of several noun settings:

-(Uistatusbarstyle) Preferredstatusbarstyle
{return
 uistatusbarstylelightcontent;
}
-(BOOL) Prefersstatusbarhidden
{return
 NO;
}

Set the view controller-based status bar appearance value to Yes in plist.
The role of these is: based on controller, dynamic control of StatusBar hidden and style.

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.