Looking at the overwhelming iOS11 news on the network, as an iOS practitioner who will be indifferent! With this curiosity in mind, I upgraded macOS to 10.12.4 (Xcode9 requires 10.12.4 and above) and downloaded and installed Xcode9.0 Beta.


From the experience of these days, Xcode9 is worthy of a good work. The code preview and compilation speed have been greatly improved. The most eye-catching thing is that Xcode9 has a separate version management system module, which supports wireless deployment and debugging in the same LAN. To be honest, I don’t want to switch to Xcode8 if I’m not afraid of problems with the project.


In the previous project, the camera function has been using the system’s own PickerView, which is not very beautiful to tell the truth. In my spare time, I have been developing a custom camera (EVNCamera: give a StarO(∩_∩)O~). In the first Beta version of Xcode9 development camera function, the original project unexpectedly crash, later found iOS11, apple do to album permissions key adjustment, the original NSPhotoLibraryUsageDescription, after iOS11, Changed to NSPhotoLibraryAddUsageDescription.

See: Cocoa Keys

But there are children’s shoes feedback using Xcode 9 Beta3 packaging applications, use the original album permissions NSPhotoLibraryUsageDescription still normal, I try to Xcode 9 Beta4 packaging, use the original album access key still crash.

NFC permission

In iOS11, apple opened up Near field communication (NFC), which is also a strategy to promote ApplePay.

In the use of the near field communication, the first in the info. The plist configuration NFCReaderUsageDescription permissions, case steps, as follows:

iOS 11 Core NFC – any sample code?

IOS11 needs to be adapted

– (CGFloat) tableView: (UITableView *) tableView heightForHeaderInSection: (NSInteger) section does not perform

UITableView (self-sizing) is enabled by default, which means that we no longer need to calculate the height of the cell by ourselves. If we set these two attributes and restrict the layout, the system will calculate the height of the cell automatically. Self-sizing is enabled by default after iOS11, including Headers and footers. If estimatedRowHeight is not used in the project, it will be weird in iOS11, because before iOS11, estimatedRowHeight defaults to 0, and self-sizing automatically turns on. Both contentSize and contentOffset are subject to change. You can disable it in the following ways:

self.tableView.estimatedRowHeight = 0;

self.tableView.estimatedSectionHeaderHeight = 0;

self.tableView.estimatedSectionFooterHeight = 0;

AutomaticallyAdjustsScrollViewInsets abandoned, TabView, CollectionView spacing problems

The solution

AutomaticallyAdjustsScrollViewInsets attribute is no longer used, we need to use the UIScrollView

contentInsetAdjustmentBehavior

Property to replace it.

Set the appropriate enumeration

1

2

3

4

5

6 the if (@ the available (iOS11.0, *)) {

self.tableView.contentInsetAdjustmentBehavior=UIScrollViewContentInsetAdjustmentNever;

}

else{

self.automaticallyAdjustsScrollViewInsets=NO;

}

NSLocationAlwaysAndWhenInUseUsageDeion

In iOS11 original NSLocationAlwaysUsageDeion was downgraded to a NSLocationWhenInUseUsageDeion. Therefore, in the original project using requestAlwaysAuthorization location permissions, but not in the file configuration NSLocationAlwaysAndWhenInUseUsageDeion, system frame not pop up.

The iPhone X status bar icon element structure has changed

Before we by traversal foregroundView UIStatusBarDataNetworkItemView can find wifi signal strength.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16-(void)getSignalStrength{

UIApplication*app=[UIApplicationsharedApplication];

NSArray*subviews=[[[app valueForKey:@”statusBar”] valueForKey:@”foregroundView”] subviews];

NSString*dataNetworkItemView=nil;

for(idsubview insubviews){

if([subview isKindOfClass:[NSClassFromString(@”UIStatusBarDataNetworkItemView”)class]]){

dataNetworkItemView=subview;

break;

}

}

intsignalStrength=[[dataNetworkItemView valueForKey:@”_wifiStrengthBars”] intValue];

NSLog(@”signal %d”,signalStrength);

}

The elements and layout of the iPhoneX have been changed due to the design of the iPhoneX.

1

idstatusBar=[[UIApplicationsharedApplication] valueForKeyPath:@”statusBar”];

Execute after breakpoint

1

po[statusBar recursiveDescription]

You can view the new structure

Two: the navigation bar

1. There is a new big title style in the navigation bar. The default setting is not on, so there is no need to change it.

2. TitleView supports Autolayout, which requires that the titleView must be self-extensible or implementable – intrinsicContentSize

The solution

1

2

3-(CGSize)intrinsicContentSize{

returnUILayoutFittingExpandedSize;

}

Three: ScrollView

If you have some text inside the UI scrollView that is contained in the navigation controller, now normally navigationContollers will pass in a contentInset to its topmost viewController’s scrollView, AdjustedContentInset (adjustContentInset) adjustContentInset (adjustedContentInset) adjustContentInset (AdjuadjustContentInSet)


typedef NS_ENUM(NSInteger, UIScrollViewContentInsetAdjustmentBehavior) {

UIScrollViewContentInsetAdjustmentAutomatic,

UIScrollViewContentInsetAdjustmentScrollableAxes,

UIScrollViewContentInsetAdjustmentNever,

UIScrollViewContentInsetAdjustmentAlways,

}

@property(nonatomic) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior;

@property(nonatomic, readOnly) uiedGeInAdjustedContentInSet;

//adjustedContentInset Delegate when the value is changed

  • (void)adjustedContentInsetDidChange;

  • (void)scrollViewDidChangeAdjustedContentInset:(UIScrollView *)scrollView;

UIScrollViewContentInsetAdjustmentBehavior is an enumerated type, values are the following:

Automatic, like scrollableAxes,scrollView automatically calculates and ADAPTS top and bottom margins and sets margins if the scrollView is not scrollable.

ScrollableAxes calculates internal margins automatically.

Never does not calculate inner margins

Always Calculates the inner margins based on safeAreaInsets

You watch if you feel that you can also point a wave of attention with collection!