1 Considerations for Xib files
After you use Xcode8 to open the Xib file, a prompt appears.
You can choose Choose Device.
Then everyone will find the layout ah, frame chaos, only need to update frame. Such as
Note: If you follow the above steps and open xib with Xcode7, the error will be reported.
Workaround: Need to delete xib inside
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
This, as well as the ToolsVersion in < document > and < plugIn > version to the value in your normal xib file.
2 push
such as the section, do not forget to open. All push platforms, whether Aurora or anything, must be turned on to receive the push.
Push Agent <UNUserNotificationCenterDelegate> IOS10 receive notification is no longer in the [application: didReceiveRemoteNotification:] method to deal with, IOS10 launch new proxy method, receive and process all kinds of notifications (local or remote)
-(void) Usernotificationcenter:(Unusernotificationcenter *) Center willpresentnotification:(unnotification *) notification Withcompletionhandler:(void (^)( unnotificationpresentationoptions)) Completionhandler {//app receives notification at the front NSLog(@"========%@", notification);} - (void) Usernotificationcenter:(unusernotificationcenter *) Center Didreceivenotificationresponse: (unnotificationresponse *) Response Withcompletionhandler:(void (^)()) Completionhandler {// Click on the notification to enter the app NSLog(@"response:%@", Response);}
3 masking Xcode 8 disorganized log
After updating the Xcode8, the newly created project will print a bunch of logs that are inexplicable to read.
such as these
subsystem: com.apple.UIKit, category: HIDEventFiltered, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1,
The shielding method is as follows:
Xcode8 inside Edit Scheme Run Arguments , Environment Variables add inside
OS_ACTIVITY_MODE = Disable
If you have written or printed log, please check the checkmark again, you can solve the
Considering the addition of the above content after Xcode8, the real machine debugging may be an exception, you can customize a macro definition, to do the log output.
#ifdef DEBUG#define DDLOG(...) printf(" %s\n",[[NSString stringWithFormat:__VA_ARGS__]UTF8String]);#define DDLOG_CURRENT_METHOD NSLog(@"%@-%@", NSStringFromClass([self class]), NSStringFromSelector(_cmd))#else#define DDLOG(...) ;#define DDLOG_CURRENT_METHOD ;#endif
4 Permissions and related settings
IOS10 Call album will crash the following information
it attempted to access privacy-sensitive data without a usage description. The app‘s Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.
The general meaning is that the app lacks a permission description to get private (sensitive) data. We need to have a value in the Info.plist file that has a name called Nsphotolibraryusagedescription to explain why the application needs to use this data, yes, the key to get the album resource is Nsphotolibraryusagedescription
The following key values have been added to the plist file:
This time again click Get Picture resource, pop up a get permission of greeting, do not crash:
In addition to the permissions of the album, iOS10 after the following permission request is also required to fill in the request description
//麦克风权限Privacy - Contacts Usage Description //通讯录权限Privacy - Camera Usage Description //摄像头权限Privacy - NSSiriUsageDescription //Siri的权限Privacy - Bluetooth Peripheral Usage Description //蓝牙Privacy - Reminders Usage Description //提醒事项Privacy - Motion Usage Description //运动与健康Privacy - Media Libaray Usage Description //媒体资源库Privacy - Calendars Usage Description //日历
5 IOS 10 Start Project Some text display is not complete problem
I used Xcode 8 and Xcode 7.3 to test the next, such as:
Create a label and then make it adaptive size, the font size is 17 the width of the last output is not the same, we look at the following data to know why upgrade iOS 10 after the text in the app is not fully displayed:
| Xcode 8 Printing |
Xcode 7.3 Printing |
| 1 Text width: 17.5 |
1 Text width: 17 |
| 2 Text width: 35 |
2 Text width: 34 |
| 3 Text width: 52 |
3 Text width: 51 |
| 4 Text width: 69.5 |
4 Text width: 68 |
| 5 Text Width: 87 |
5 Text width: 85 |
| 6 Text width: 104 |
6 Text width: 102 |
| 7 Text width: 121.5 |
7 Text width: 119 |
| 8 Text width: 139 |
8 Text width: 136 |
| 9 Text width: 156 |
9 Text width: 153 |
| 10 Text width: 173.5 |
10 Text width: 170 |
The English alphabet will also have this problem, I passed the test, and later found that the English alphabet is not a problem, only the Chinese characters have problems.
The solution that is currently feasible:
//@property(nonatomic) BOOL adjustsFontSizeToFitWidth; // default is NOlabel.adjustsFontSizeToFitWidth = YES;//设置成YES就可以啦
6 Xib Set the fixed size to get the control size in the code becomes (0,0,1000,1000)
The size of the - (void)updateConstraints control to be obtained from or UIView - (void)drawRect:(CGRect)rect .
- (void)updateConstraints{ [super updateConstraints];}- (void)drawRect:(CGRect)rect{ [super drawRect:rect];}
The size of the control to get from in Uiviewcontroller - (void)viewDidLayoutSubviews .
- (void)viewDidLayoutSubviews{ [super viewDidLayoutSubviews];}
7 Xcode 8 warning issue with Xib awakefromnib
Before Xcode 8 We used xib initialization-(void) awakefromnib {} It's okay to write this, but in Xcode 8 there's the following warning:
If you don't like the warning, you should definitely add [super awakefromnib]; Let's take a look at the official note:
Must call the super implementation of awakefromnib to give, parent classes the opportunity to perform any additional in Itialization they require. Although the default implementation of this method does nothing, many UIKit classes provide NON-EMPTY implementations. The super implementation at any point during your own awakefromnib method.
Reference
http://www.jianshu.com/p/484a909b4772
IOS10 and Xcode8 adaptation