Recently, I have a iOS7 adaptation of the project, delayed use of 7.0SDK is because the old project use iOS7.0 have some problems, taking advantage of this opportunity, I detailed the adaptation iOS7 need to pay attention to a few places. The records are as follows:
One,iOS7 UITableViewCell adaptation
(1) iOS7 UITableViewCell Background color
Before iOS7 UITableViewCell backgroundcolor is transparent, but in iOS7 the default white background, if using IOS7 SDK UITableViewCell display is not normal, only need to modify:
[Cell Setbackgroundcolor:[uicolor Clearcolor]];
(2) iOS7 UITableViewCell Hierarchical Relationship
Before iOS7, there might be a code like this when you find the UITableViewCell in UIButton sub-view on UITableViewCell: [[Sender Superview] Superview]
This code will definitely crash on IOS7.
IOS7 Previously, we generally add the view to the UITableViewCell Contentview, Contentview's parent view is UITableViewCell, the above code is no problem. But on IOS7, the parent view of UITableViewCell's Contentview is not a detailed introduction to this class in uitableviewcellcontentview[sdk, so [sender Superview] Superview] can not find UITableViewCell. A simple application of the scrolling view Uiscrollview for iOS research uiscrollview unclear
In fact, the correct approach here should be:
Implement the UIButton trigger method in the class that inherits UITableView:
| 123456 |
-(void)ButtonClick:(UIButton *)Button{ Cgpointbuttonposition= [ButtonConvertpoint:CgpointzeroToview: Self]; Nsindexpath *Indexpath= [ SelfIndexpathforrowatpoint:buttonposition]; UITableViewCell *Cell= (UITableViewCell *)[ SelfCellforrowatindexpath:Indexpath]; //do something} |
TwoiOS7 Uiviewcontroller Adaptation
The biggest change is that Uiviewcontroller is displayed in full screen by default.
(1) Height of navigation bar
IOS7 before the navigation bar height of 44,ios7 is full-screen layout, the navigation bar height includes the status bar height 20 becomes 64. If you do not fit the status bar, the navigation bar will be obscured.
(2)Edgesforextendedlayout
The following values are taken
Uirectedgenone = 0,
Uirectedgetop = 1 << 0,
Uirectedgeleft = 1 << 1,
Uirectedgebottom = 1 << 2,
Uirectedgeright = 1 << 3,
Uirectedgeall
This value is only valid if the current view has Navigationbar or tabBar, and if it is a custom navigationbar/tabbar, this value does not work. It is marked from the upper and lower direction of the page extension, that is, the navigation bar page is also counted in the View Display section. IOS7 default is the full screen layout, the value is Uirectedgeall. If it was previously compiled from iOS 6.0SDK, it will be changed to
Self.edgesforextendedlayout = Uirectedgenone to show no problem on iOS 7.
The same is also [effective when there are navigationbar/tabbar];
Self.extendedlayoutincludesopaquebars = NO;
Specifies whether the view extends to the area of bar when the bar is using an opaque picture, the default value is No. So if we customize the background image of the navigation bar, the view starts from below the navigation bar and does not extend to the navigation bar area.
Self.modalpresentationcapturesstatusbarappearance = NO;
Self.tabBarController.tabBar.translucent = NO;
Self.navigationController.navigationBar.translucent = no;//Set nav bar Translucent effect
(3) Automaticallyadjustsscrollviewinsets
The first UIView added to Uiviewcontroller, such as Uiscrollview (including its subclasses, such as Uitablevie), will automatically reserve some whitespace at the top and bottom, The main purpose is to scroll through the translucent navigation bar or tabbar under the translucent effect can be seen, whether or not to reserve white space can be controlled by the uiviewcontroller of the Automaticallyadjustsscrollviewinsets property.
ThreeiOS7 status Bar
There are several xxx-info.plist properties that involve the status bar action:
Status Bar Style
Status Bar is initially hidden
Status Bar Tinting Parameters
View controller-based status bar appearance
Where the status bar is initially Hidden,status bar style (tekuba.net test seems to have no effect on iOS6) marks the global setting: whether the status bar is hidden, and the style of the status bar.
The corresponding code is:
[[UIApplication sharedapplication] Setstatusbarhidden:no Withanimation:no];
[[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent];
In general, we want the program to hide the status bar when it starts and the program starts to show the status bar when it finishes entering the foreground, this time you can set the plist file's status bar is initially hidden to Yes, hide the status bar first, Then set it in the Didfinishlaunchingwithoptions method:
[[UIApplication sharedapplication] Setstatusbarhidden:no Withanimation:no] Displays the status bar.
1,ios7 previously cannot control the display of the status bar individually for each uiviewcontroller, only call Setstatusbarhidden/setstatusbarstyle Modify the status bar display or style when needed
After 2,ios7, the status bar is transparent.
The plist parameter has one more view controller-based status bar appearance.
IfView controller-based status bar appearanceFor no, the status bar is not controlled by the Uiviewcontroller, so the control of the status bar is the same as in the previous iOS7, where the Setstatusbarhidden is performed where modifications are required.
If set to Yes, the status bar will change depending on the configuration of each uiviewcontroller, and the following two methods need to be overloaded if you need to change the status bar in Uiviewcontroller:
<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" wrap="soft" readonly="" data-settings="dblclick">-(Uistatusbarstyle) Preferredstatusbarstyle {return uistatusbarstylelightcontent;//status bar style}-(BOOL) Preferss Tatusbarhidden {return no;//status bar is hidden}</textarea>
| 123456789 |
-(Uistatusbarstyle)Preferredstatusbarstyle { returnuistatusbarstylelightcontent;//status bar style} - (BOOL)Prefersstatusbarhidden { returnNO;//The status bar is hidden} |
The two methods are automatically executed when the Uiviewcontroller is initialized, and if you need to refresh the status bar style, call [self setneedsstatusbarappearanceupdate] and the system will call both methods automatically.
Four, the specific implementation
If you are using the system's own navigation bar and tab bar, then the above settings will basically be no problem. If you have a custom navigation bar and a tab bar, you need to make minor changes:
Judging whether iOS7
#define ISIOS7 ([[[Uidevice Currentdevice] systemversion] Floatvalue] >= 7)
#define Nav_height (isIOS7 64:44)//navigation bar height
#define NAV_HEIGHT_NO_STATUSVIEW 44//navigation bar height-no status bar included
#define NAV_START_Y (Nav_height–nav_height_no_statusview)//Start Y value when the navigation bar is drawn
When you create Windows
Self.window = [[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];
When you create a custom navigation bar with a height of nav_height, draw the custom view with the start Y coordinate of nav_start_y.
In some places it may also be necessary to add:
<textarea class= "Crayon-plain print-no" style= "line-height:15px!important; Overflow:hidden; FONT-SIZE:12PX!important; z-index:0; opacity:0; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; Tab-size:4; "wrap=" soft "readonly data-settings=" DblClick ">if (isIOS7) {Self.automaticallyadjustsscrollviewinse ts = NO; } </textarea>
| 123 |
If(isIOS7) { self . /c11>automaticallyadjustsscrollviewinsets= NO; } |
Detailed instructions for using the IOS7 adaptation of iOS research