iOS 10
1. 訪問權(quán)限崩潰問題
如果打開APP后點擊有關(guān)權(quán)限訪問后直接Crash了則需要在需要在info.plist文件中進(jìn)行相關(guān)配置(藍(lán)牙,日歷,相機(jī),相冊,相機(jī),聯(lián)系人,健康等權(quán)限...)
權(quán)限配置步驟:
- 打開項目中的info.plist文件
- 在info.plist文件Add Row一行后選擇相應(yīng)的權(quán)限進(jìn)行添加
- 先去相應(yīng)的Key,Value 應(yīng)該可以隨便填寫
如果一個個添加嫌麻煩可以全部添加到plist文件中
打開plist源文件后添加如
<key>NSBluetoothPeripheralUsageDescription</key>
<string>App需要您的同意,才能訪問藍(lán)牙</string>
<key>NSCalendarsUsageDescription</key>
<string>App需要您的同意,才能訪問日歷</string>
<key>NSCameraUsageDescription</key>
<string>App需要您的同意,才能訪問相機(jī)</string>
<key>NSHealthShareUsageDescription</key>
<string>App需要您的同意,才能訪問健康分享</string>
<key>NSHealthUpdateUsageDescription</key>
<string>App需要您的同意,才能訪問健康更新 </string>
<key>NSHomeKitUsageDescription</key>
<string>App需要您的同意,才能訪問家庭 </string>
<key>NSContactsUsageDescription</key>
<string>App需要您的同意,才能訪問通訊錄 </string>
<key>NSLocationAlwaysUsageDescription</key>
<string>App需要您的同意,才能始終訪問位置</string>
<key>NSLocationUsageDescription</key>
<string>App需要您的同意,才能訪問位置</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>App需要您的同意,才能在使用期間訪問位置</string>
<key>NSAppleMusicUsageDescription</key>
<string>App需要您的同意,才能訪問媒體資料庫</string>
<key>NSMicrophoneUsageDescription</key>
<string>App需要您的同意,才能訪問麥克風(fēng)</string>
<key>NSMotionUsageDescription</key>
<string>App需要您的同意,才能訪問運(yùn)動與健身</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>App需要您的同意,才能訪問相冊</string>
<key>NSRemindersUsageDescription</key>
<string>App需要您的同意,才能訪問提醒事項</string>
<key>NSSiriUsageDescription</key>
<string>App需要您的同意,才能訪問Siri</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>App需要您的同意,才能訪問語音識別</string>
<key>NSVideoSubscriberAccountUsageDescription</key>
<string>App需要您的同意,才能訪問視頻用戶賬戶</string>```
#2. nullable報錯問題
使用Xcode8之后,需要刪除nullable否則報錯
-(void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error```
3. ATS(App Transport Security) 網(wǎng)絡(luò)適配問題
- iOS 9時,默認(rèn)HTTS的網(wǎng)絡(luò)是被禁止的, 但可以通過向info.plist文件中添加NSAppTransportSecurity,并將NSAllowsArbitraryLoads設(shè)置為YES來禁用ATS。但是,從2017年1月1日起,所有新提交的APP默認(rèn)不允許配置NSAllowsArbitraryLoads來繞過ATS的限制,所以你的APP應(yīng)盡早使用HTTPS進(jìn)行內(nèi)容訪問,以避免APP被拒絕風(fēng)險。
- 如果APP中如果集成了第三方的SDK,則可以通過NSAppTransportSecurity中NSExceptionDomains設(shè)置白名單的方式對特定的域名開放HTTP內(nèi)容來通過審核。
NSExceptionDomains設(shè)置方法 - 在NSAppTransportSecurity 中新加入了NSAllowsArbitraryLoadsInWebContent鍵,允許任意web頁面加載,同時蘋果會用 ATS 來保護(hù)你的app。
4.新增UIViewPropertyAnimator類
類特點:
1.可中斷性
2.可擦除
3.可反轉(zhuǎn)性
4.豐富的動畫時間控制功能
//初始化屬性動畫器
UIViewPropertyAnimator *viewPropertyAnimator = [[UIViewPropertyAnimator alloc] initWithDuration:5.f curve:UIViewAnimationCurveLinear animations:^{
[self.view setAlpha:0.3];
}];
[viewPropertyAnimator startAnimation];
5.Notification(通知)
- 所有相關(guān)通知被統(tǒng)一到了UserNotifications.framework框架中。
- 增加了撤銷、更新、中途還可以修改通知的內(nèi)容。
- 通知中可以加入視頻、圖片,自定義通知的展示等等。
- 相對之前的通知來說更加好用易于管理,并且進(jìn)行了大規(guī)模優(yōu)化。
- 對于權(quán)限問題進(jìn)行了優(yōu)化,申請權(quán)限就比較簡單了(本地與遠(yuǎn)程通知集成在一個方法中)。
通知相關(guān)參考
6.UIStatusBar方法過期
過期方法:
// Setting the statusBarStyle does nothing if your application is using the default UIViewController-based status bar system.
@property(readwrite, nonatomic) UIStatusBarStyle statusBarStyle NS_DEPRECATED_IOS(2_0, 9_0, "Use -[UIViewController preferredStatusBarStyle]") __TVOS_PROHIBITED;
- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle animated:(BOOL)animated NS_DEPRECATED_IOS(2_0, 9_0, "Use -[UIViewController preferredStatusBarStyle]") __TVOS_PROHIBITED;
// Setting statusBarHidden does nothing if your application is using the default UIViewController-based status bar system.
@property(readwrite, nonatomic,getter=isStatusBarHidden) BOOL statusBarHidden NS_DEPRECATED_IOS(2_0, 9_0, "Use -[UIViewController prefersStatusBarHidden]") __TVOS_PROHIBITED;
- (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation NS_DEPRECATED_IOS(3_2, 9_0, "Use -[UIViewController prefersStatusBarHidden]") __TVOS_PROHIBITED;```
新方法:
if UIKIT_DEFINE_AS_PROPERTIES
@property(nonatomic, readonly) UIStatusBarStyle preferredStatusBarStyle NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to UIStatusBarStyleDefault
@property(nonatomic, readonly) BOOL prefersStatusBarHidden NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to NO
// Override to return the type of animation that should be used for status bar changes for this view controller. This currently only affects changes to prefersStatusBarHidden.
@property(nonatomic, readonly) UIStatusBarAnimation preferredStatusBarUpdateAnimation NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to UIStatusBarAnimationFade
else
- (UIStatusBarStyle)preferredStatusBarStyle NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to UIStatusBarStyleDefault
- (BOOL)prefersStatusBarHidden NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to NO
// Override to return the type of animation that should be used for status bar changes for this view controller. This currently only affects changes to prefersStatusBarHidden. - (UIStatusBarAnimation)preferredStatusBarUpdateAnimation NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to UIStatusBarAnimationFade
endif```
上面這個新方法在UIViewController.h文件中,只需要在viewController里調(diào)用即可。
- (BOOL)prefersStatusBarHidden{
return YES;
}
- (UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleDefault;
}```
##7.插件取消
Xcode8取消了三方插件的功能,好多教程破解可以繼續(xù)使用,但是可能app上線可能會被拒。
#Xcode 8
---
Xcode 8 可以創(chuàng)建iPhone,iPad,Apple Watch,Mac,Apple TV 等平臺的應(yīng)用程序。

##1. Swift 3
Swift 3對大量語法進(jìn)行了優(yōu)化及更新,會對Swift 3以前的版本會有影響,為解決此問題Xcode 8在編譯設(shè)置中支持開發(fā)者選擇Swift 2或Swift 2.3 進(jìn)行編譯。
如果一個目標(biāo)(Target)需要支持Swift 2.3, 需要在目標(biāo)(Target)的編譯設(shè)置里把Use Legacy Swift Language Version 設(shè)置成Yes

##2. 證書管理
Xcode 8添加了自動管理證書功能。
建議勾選這個選項Automatically manage signing
如未設(shè)置開發(fā)者賬號,則需要在xcode->preferences->Accounts中添加

#Xcode 8問題解決
---
##1. 代碼注釋快捷功能不能使用
解決方法
打開終端 - 輸入命令運(yùn)行:sudo /usr/libexec/xpccachectl
重啟計算機(jī)
##2. 出現(xiàn)雜亂的Debug
會在Debug窗口出現(xiàn)如下信息
>2016-10-10 16:12:37.746003 HHRouterExample[9121:339626] 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, privacy_setting: 2, enable_private_data: 0
屏蔽方法
選擇Product-> Scheme -> Edit Scheme -> Run -> Arguments 然后在Environment Variables里添加`OS_ACTIVITY_MODE = Disable`

##官方鏈接地址
---
[UserNotifications](https://developer.apple.com/reference/usernotifications)