IOS11 those pits that fit with the IPhone x (hold more ...)

Source: Internet
Author: User

List of directory issues

1.xcode9 Adding a resource file does not get a path problem

Customizing view display issues on the 2.IOS11 system navigation bar

3.UITableView occlusion Display problem (three lines of code resolved, put to base class)

4. Adaptation Iphonex screen principle

5. Settings for some constants of the adaptation process

6. Uiscrollview drift problem (mostly Iphonex)

Black area problem running on 7.iPhone X

8. Some issues that cause Iphonex to get a network state crash

9. Some design demonstrations on the bottom of the iphone x

10. About Iphonex's Home bar (Homeindicator)

11. Changes in IOS11 permissions

12.IOS11 Uicollectionview's scroll indicator and other issues that are obscured by group views

13.IOS11 cannot eject keyboard problem

14.IOS11 array syntax sugar?? Change of replacement method

1. XCode9 Add resource file cannot get path problem

XCode9 calls [[NSBundle Mainbundle] pathForResource:resourceNameofType:nil]; method to get the file path, return to nil. Add the correct way like 1,

Figure 1 Adding a resource option

But XCode9 buried a pit like 2, click on the resource file to find the file options

Figure 2 Resource file options

The red box area is not checked by default, just check the box to resolve it. The reason is: Xcode9 add files using AddFile drag-and-drop files are not automatically added to compile Sources and Copy Bundle Resources.

2. iOS11 the display problem of the custom view on the system navigation bar

Previous code set the navigation bar:

Self.navigationItem.titleView = CustomView;

Such problems would arise, such as 3,

Figure 3 Navigation bar Error

The reason for the mess is because iOS11 adjusts the structure of the navigation bar layer. Quick and easy way to modify, directly on the code,

Self.navigationItem.hidesBackButton = YES;
[Self.navigationController.navigationBaraddSubview:YourCustomView];

But you need to remove your custom view in the Dealloc of the controller,

4 Custom Views for modification

Figure 4

3. Occlusion display problem in UITableView (three lines of code resolved, put to base class)
IOS11 adaptation
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
4. Adaptation Iphonex screen principle Figure 5 Iphonex vertical Screen Figure 6 Iphonex horizontal Screen

design principles: Let the line of operable, unstoppable controls or views appear in the blue area of Figure 5, Figure 6 (safe area Safearea).

Top hazardous area Distance: 44

Bottom hazardous area Distance: 34

5. Settings for some constants of the adaptation process
#define YYISIPHONEX [[UIScreen mainscreen] bounds].size.width >=375.0f && [[UIScreen mainscreen] bounds]. Size.Height >=812.0f&& Yyis_iphone
#define Yyis_iphone (ui_user_interface_idiom () = = Uiuserinterfaceidiomphone)

#define Kstatusbarheight (cgfloat) (Yyisiphonex? ( ):(20)))
Navigation Bar Height
#define KNAVBARHBELOW7 (44)
Status bar and nav bar total height
#define KNAVBARHABOVE7 (cgfloat) (Yyisiphonex? ( ):(64)))
Tabbar height
#define Ktabbarheight ( cgfloat) (Yyisiphonex? ( 49+34):(49)))
Top Safety Zone away from height
#define Ktopbarsafeheight ( cgfloat) (Yyisiphonex? ( ):(0)))
Bottom safety Zone away from height
#define Kbottomsafeheight ( cgfloat) (Yyisiphonex? ( ):(0)))
Iphonex status bar Height difference value
#define Ktopbardifheight (cgfloat) (Yyisiphonex? ( ):(0))
6. Uiscrollview drift problem (mostly Iphonex)

If the Uiscrollview frame and the contentsize height or width are consistent but also cause drift problems, the following line of code can be done.

if (@available (ios11,*)) {_scrollview.contentinsetadjustmentbehavior=uiscrollviewcontentinsetadjustmentnever;}

At the same time, if the push enters the WebView page, there will be a black edge at the bottom of the flash over, also can be resolved by this method.

If you have trouble, each scrollview and its subclasses to set, you can also use the following methods

if(@available(iOS 11.0, *)){[[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
7.Black area problem running on IPhone X

Start diagram problem, use Launchscreen to do the start diagram or modify the Launchimage in assets, add Iphonex launch Figure 1125*2436 (PX) vertical screen mode.

8. Some issues that cause Iphonex to get a network state crash

Directly on the code, no need to get the layer name through KVC get the network status, once and for all! (because you are not familiar with the markdown syntax, the following code should be self-indented

#import <CoreTelephony/CTTelephonyNetworkInfo.h>
+ (NSString *) Getnetworkinfo {
NSString *strnetworkinfo = @ "No Network";
struct Sockaddr_storage zeroaddress;
Bzero (&zeroaddress,sizeof (zeroaddress));
Zeroaddress.ss_len = sizeof (zeroaddress);
zeroaddress.ss_family = af_inet;
Recover reachability Flags
Scnetworkreachabilityref defaultroutereachability = scnetworkreachabilitycreatewithaddress (NULL, struct sockaddr *) &zeroaddress);
Scnetworkreachabilityflags flags;
Get a connection flag
BOOL didretrieveflags = Scnetworkreachabilitygetflags (defaultroutereachability,&flags);
Cfrelease (defaultroutereachability);
If you cannot get the connection flag, you cannot connect to the network and return directly
if (!didretrieveflags) {return strnetworkinfo;} BOOL isreachable = ((Flags & kscnetworkflagsreachable)!=0); BOOL needsconnection = ((Flags & kscnetworkflagsconnectionrequired)!=0); if (!isreachable | | needsconnection) {return strnetworkinfo;} Network type judgment
if ((Flags & kscnetworkreachabilityflagsconnectionrequired) = = 0) {Strnetworkinfo = @ "WIFI";}
if ((Flags & kscnetworkreachabilityflagsconnectionondemand)! = 0) | | (Flags & kscnetworkreachabilityflagsconnectionontraffic)! = 0) {if (Flags & kscnetworkreachabilityflagsinterventionrequired) = = 0) {Strnetworkinfo = @ "WIFI";}}
    if ((Flags & Kscnetworkreachabilityflagsiswwan) ==kscnetworkreachabilityflagsiswwan) {if ([[[ Uidevice Currentdevice] systemversion] floatvalue] >= 7.0) {Cttelephonynetworkinfo * info = [[Cttelephonynetworkinfo a] Lloc] init]; NSString *currentradioaccesstechnology = info.currentradioaccesstechnology;if (currentradioaccesstechnology) {if ([ Currentradioaccesstechnology Isequaltostring:ctradioaccesstechnologylte]) {strnetworkinfo =  @ "4G";} else if ([ Currentradioaccesstechnology Isequaltostring:ctradioaccesstechnologyedge] | | [Currentradioaccesstechnologyisequaltostring:ctradioaccesstechnologygprs]) {strnetworkinfo =  @ "2G";} else {strnetworkinfo =  @ "3G";}}} else {if ((Flags & kscnetworkreachabilityflagsreachable) = = kscnetworkreachabilityflagsreachable) {if (Flags & kscnetworkreachabilityflagstransientconnection) = = kscnetworkreachabilityflagstransientconnection) {if (Flags & kscnetworkreachabilityflagsconnectionrequired) = = Kscnetworkreachabilityflagsconnectionrequired) {strnetworkinfo = @ "2G";} else {strnetworkinfo = @ "3G";}}}}
if ([Strnetworkinfo isequaltostring: @ "No Network"]) {strnetworkinfo = @ "WWAN";}
return strnetworkinfo;
}
9. Some examples of the design model for the bottom of the iphone x

Demonstration Diagram II

Figure III of the model

10. About Iphonex's Home bar (Homeindicator)

Look at 7 first,

Figure 7 Horizontal screen look at the sexy girl video

This kind of experience is actually not good (also how to use English to tease the sister?), so in order to prevent such a problem, Apple actually provides the method of hiding the homeindicator, as below,

-(BOOL) Prefershomeindicatorautohidden {
return YES;
}

In the VC inside rewrite Prefershomeindicatorautohidden return YES (default is NO), the home bar can be automatically hidden, this method is the screen if there is no interactive event response, the delay of about 2 seconds will callback this method.

11. Changes in IOS11 permissions

1. Location PROBLEM: Unable to locate, the first time use did not eject the Location Request dialog box.

Reason: Due to the change of the key of IOS11 's location permission, Nslocationwheninuseusagedescription and nslocationalwaysandwheninusaged are always allowed on nslocationalwaysusagedescription basis prior to iOS11 Escription. Specific Reference blog: http://blog.csdn.net/dangyalingengjia/article/details/77965029

2. Album Permissions issue: A crash occurred while reading and writing the photo album on IOS11.

Cause: The key for IOS11 album related permissions has changed. Users who do not have permission to access the album cause a crash.

The key before IOS11 is Nsphotolibraryusagedescription, and IOS11 's key changes to Nsphotolibraryaddusagedescription. As with the location key, because key is not compatible, it is necessary to retain the original key to be compatible with the previous version of IOS11.

IOS11 Uicollectionview Scroll indicator and other issues that are obscured by group views

Problem such as 8 red box area,

Figure 8 Uicollectionview Bug diagram

This is caused by a problem with the z-coordinate of the group view, with the following two workarounds

The first: Override the Layoutsubviews method in this class < apply to small-scale >

-(void) Layoutsubviews {
[Super Layoutsubviews];
self.layer.zPosition = 0;
}

The second type: Customize a layer and rewrite its zposition get method. Then add a classification method to the group view class, overriding the Layerclass method.

Custom layer:

@implementation Yyzpositionzerolayer

-(CGFloat) zposition {
return 0;
}
@end

Add Category Rewrite Group view Layerclass method:

@implementationUICollectionReusableView (Zpositionzero)
+ (Class) Layerclass {
Return[yyzpositionzerolayer class];
}
@end
IOS11 cannot eject keyboard problems

Problem Description: At some point you will find that when you call the Becomefirstresponder method, the keyboard does not respond and the system keyboard does not eject.

Problem finding: If the Uialertview pop-up dialog was used before the call, it would cause the system keyboard to fail to eject, guessing because the Uialertview exists windowlevel greater than levelnormal when it disappears through the Windows window Window took him as a keywindow.

Problem solving: If your project is still using Uialertview (2_0,9_0), it is recommended to replace it with Uialertcontroller.

14.IOS11 array syntax sugar?? Change of replacement method

Before the iOS11,

Array[i] syntax sugar is replaced by [array objectatindex:i]

After the iOS11,

Array[i] syntax sugar is replaced by [array objectatindexedsubscript:i]

Children's shoes with dynamic switching methods need attention

IOS11 those pits that fit with the IPhone x (hold more ...)

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.