權(quán)限崩潰問題
控制臺(tái)日志:This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSContactsUsageDescription key with a string value explaining to the user how the app uses this data.
意思是說:你需要在info.plist文件 添加一個(gè)“NSContactsUsageDescription ”的Key,Value添加一個(gè)描述。
1,在項(xiàng)目中找到info.plist文件,右擊有個(gè) Open As,以Source Code 的形式打開
2,分別復(fù)制 以下 Value 和Key,Key 一定不能錯(cuò),Value 可以隨便填寫
相機(jī)權(quán)限描述:
<key>NSCameraUsageDescription</key>
<string>cameraDesciption</string>
通信錄:
<key>NSContactsUsageDescription</key>
<string>contactsDesciption</string>
麥克風(fēng):
<key>NSMicrophoneUsageDescription</key>
<string>microphoneDesciption</string>
相冊:
<key>NSPhotoLibraryUsageDescription</key>
<string>photoLibraryDesciption</string>
eg:其他權(quán)限描述,debug 控制臺(tái)都會(huì)有輸出的,自行添加就OK
xib和storyboard布局顯示問題
使用Xcode8偶然打開了項(xiàng)目中的storyboard文件,然后跑起項(xiàng)目,卻發(fā)現(xiàn)界面全亂了?;蛘哒f界面無法顯示等問題。
經(jīng)過一番探究后,發(fā)現(xiàn)Xcode8對xib和storyboard做出了一些修改,在awakeFromNib和viewDidLoad方法中拿自己拖上去的控件的frame均變成了(0, 0, 1000, 1000),若直接在此使用控件frame進(jìn)行二次修改,如:修改A控件的寬為B控件的一半,則B控件實(shí)際當(dāng)前的寬是1000,就會(huì)造成混亂,或者界面無法顯示等。解決辦法是在使用原控件frame之前調(diào)一次layoutIfNeeded方法。
最簡單的方法就是在viewDidLoad方法中加入[self.view layoutIfNeeded]。
- (void)viewDidLoad {
[super viewDidLoad];
[self.view layoutIfNeeded]; // 調(diào)用此方法
}
控制臺(tái)輸出不相關(guān)信息
解決方法:EditScheme -> 左側(cè)Run -> 右側(cè)Arguments -> 下方Environment Variables -> 添加 OS_ACTIVITY_MODE = disable