iOS 10
1. 訪問(wèn)權(quán)限崩潰問(wèn)題
如果打開(kāi)APP后點(diǎn)擊有關(guān)權(quán)限訪問(wèn)后直接Crash了則需要在需要在info.plist文件中進(jìn)行相關(guān)配置(藍(lán)牙焰宣,日歷蒿讥,相機(jī)达椰,相冊(cè)挂绰,相機(jī)屎篱,聯(lián)系人,健康等權(quán)限...)
權(quán)限配置步驟:
- 打開(kāi)項(xiàng)目中的info.plist文件
- 在info.plist文件Add Row一行后選擇相應(yīng)的權(quán)限進(jìn)行添加
- 先去相應(yīng)的Key葵蒂,Value 應(yīng)該可以隨便填寫
如果一個(gè)個(gè)添加嫌麻煩可以全部添加到plist文件中
打開(kāi)plist源文件后添加如
<key>NSBluetoothPeripheralUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)藍(lán)牙</string>
<key>NSCalendarsUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)日歷</string>
<key>NSCameraUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)相機(jī)</string>
<key>NSHealthShareUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)健康分享</string>
<key>NSHealthUpdateUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)健康更新 </string>
<key>NSHomeKitUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)家庭 </string>
<key>NSContactsUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)通訊錄 </string>
<key>NSLocationAlwaysUsageDescription</key>
<string>App需要您的同意,才能始終訪問(wèn)位置</string>
<key>NSLocationUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)位置</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>App需要您的同意,才能在使用期間訪問(wèn)位置</string>
<key>NSAppleMusicUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)媒體資料庫(kù)</string>
<key>NSMicrophoneUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)麥克風(fēng)</string>
<key>NSMotionUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)運(yùn)動(dòng)與健身</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)相冊(cè)</string>
<key>NSRemindersUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)提醒事項(xiàng)</string>
<key>NSSiriUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)Siri</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)語(yǔ)音識(shí)別</string>
<key>NSVideoSubscriberAccountUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)視頻用戶賬戶</string>```
#2. nullable報(bào)錯(cuò)問(wèn)題
使用Xcode8之后交播,需要?jiǎng)h除nullable否則報(bào)錯(cuò)
-(void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error```
3. ATS(App Transport Security) 網(wǎng)絡(luò)適配問(wèn)題
- iOS 9時(shí),默認(rèn)HTTS的網(wǎng)絡(luò)是被禁止的, 但可以通過(guò)向info.plist文件中添加NSAppTransportSecurity践付,并將NSAllowsArbitraryLoads設(shè)置為YES來(lái)禁用ATS秦士。但是,從2017年1月1日起永高,所有新提交的APP默認(rèn)不允許配置NSAllowsArbitraryLoads來(lái)繞過(guò)ATS的限制隧土,所以你的APP應(yīng)盡早使用HTTPS進(jìn)行內(nèi)容訪問(wèn),以避免APP被拒絕風(fēng)險(xiǎn)命爬。
- 如果APP中如果集成了第三方的SDK曹傀,則可以通過(guò)NSAppTransportSecurity中NSExceptionDomains設(shè)置白名單的方式對(duì)特定的域名開(kāi)放HTTP內(nèi)容來(lái)通過(guò)審核。
NSExceptionDomains設(shè)置方法 - 在NSAppTransportSecurity 中新加入了NSAllowsArbitraryLoadsInWebContent鍵饲宛,允許任意web頁(yè)面加載皆愉,同時(shí)蘋果會(huì)用 ATS 來(lái)保護(hù)你的app。
4.新增UIViewPropertyAnimator類
類特點(diǎn):
1.可中斷性
2.可擦除
3.可反轉(zhuǎn)性
4.豐富的動(dòng)畫時(shí)間控制功能
//初始化屬性動(dòng)畫器
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)容练链。
- 通知中可以加入視頻翔脱、圖片,自定義通知的展示等等媒鼓。
- 相對(duì)之前的通知來(lái)說(shuō)更加好用易于管理届吁,并且進(jìn)行了大規(guī)模優(yōu)化错妖。
- 對(duì)于權(quán)限問(wèn)題進(jìn)行了優(yōu)化,申請(qǐng)權(quán)限就比較簡(jiǎn)單了(本地與遠(yuǎn)程通知集成在一個(gè)方法中)疚沐。
通知相關(guān)參考
6.UIStatusBar方法過(guò)期
過(guò)期方法:
// 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```
上面這個(gè)新方法在UIViewController.h文件中暂氯,只需要在viewController里調(diào)用即可。
- (BOOL)prefersStatusBarHidden{
return YES;
}
- (UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleDefault;
}```
##7.插件取消
Xcode8取消了三方插件的功能亮蛔,好多教程破解可以繼續(xù)使用痴施,但是可能app上線可能會(huì)被拒。
#Xcode 8
---
Xcode 8 可以創(chuàng)建iPhone究流,iPad辣吃,Apple Watch,Mac芬探,Apple TV 等平臺(tái)的應(yīng)用程序神得。
![Xcode 8 首界面](http://upload-images.jianshu.io/upload_images/2529977-c4a3f37cef2c061e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
##1. Swift 3
Swift 3對(duì)大量語(yǔ)法進(jìn)行了優(yōu)化及更新,會(huì)對(duì)Swift 3以前的版本會(huì)有影響偷仿,為解決此問(wèn)題Xcode 8在編譯設(shè)置中支持開(kāi)發(fā)者選擇Swift 2或Swift 2.3 進(jìn)行編譯哩簿。
如果一個(gè)目標(biāo)(Target)需要支持Swift 2.3, 需要在目標(biāo)(Target)的編譯設(shè)置里把Use Legacy Swift Language Version 設(shè)置成Yes
![支持Swift語(yǔ)言以往版本](http://upload-images.jianshu.io/upload_images/2529977-6b613df856043023.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
##2. 證書管理
Xcode 8添加了自動(dòng)管理證書功能。
建議勾選這個(gè)選項(xiàng)Automatically manage signing
如未設(shè)置開(kāi)發(fā)者賬號(hào)酝静,則需要在xcode->preferences->Accounts中添加
![自動(dòng)管理證書](http://upload-images.jianshu.io/upload_images/2529977-81d200dcecac3fa6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
#Xcode 8問(wèn)題解決
---
##1. 代碼注釋快捷功能不能使用
解決方法
打開(kāi)終端 - 輸入命令運(yùn)行:sudo /usr/libexec/xpccachectl
重啟計(jì)算機(jī)
##2. 出現(xiàn)雜亂的Debug
會(huì)在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`
![屏蔽方法](http://upload-images.jianshu.io/upload_images/2529977-df319775614e7154.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
##官方鏈接地址
---
[UserNotifications](https://developer.apple.com/reference/usernotifications)