iOS10 App適配許可權 Push Notifications 字型Frame 遇到的坑!!!!,ios10notifications
添加配置許可權
<!-- 相簿 --> <key>NSPhotoLibraryUsageDescription</key> <string>"xx"想使用您的相簿,需要您的允許</string> <!-- 相機 --> <key>NSCameraUsageDescription</key> <string>"xx"想使用您的相機,需要您的允許</string> <!-- 麥克風 --> <key>NSMicrophoneUsageDescription</key> <string>"xx"想使用您的麥克風,需要您的允許</string> <!-- 位置 --> <key>NSLocationUsageDescription</key> <string>"xx"想訪問您的位置,請您允許</string> <!-- 日曆 --> <key>NSCalendarsUsageDescription</key> <string>"xx"想訪問您的日曆,請您允許</string> <!-- 媒體資料庫 --> <key>NSAppleMusicUsageDescription</key> <string>"xx"想訪問您的媒體資料庫,請您允許</string> <!-- 藍芽 --> <key>NSBluetoothPeripheralUsageDescription</key> <string>"xx"想訪問您的藍芽,請您允許</string> <!--通訊錄 --> <key>NSContactsUsageDescription</key> <string>"xx"想訪問您的通訊錄,請您允許</string> <key>NSLocationWhenInUseUsageDescription</key> <string>請點擊“允許”。若不允許,您將無法正常使用“附近”的功能。</string>
添加Push Notifications支援
開關開啟後會自動產生xxxx.entitlements檔案
這裡需要注意幾點
產生的該檔案是否包含到你的打包工程中Bundle Resources中 如果沒有手動添加進去
如果工程有多個Target 且多個認證在一起建議不要使用 Automatically manage signing
採用下面的這種方法
總結
第一個 我們的項目是多個app時的所以在配置認證的時候要指定對應的認證,自動適配會適配不準確,因為我們的多個工程分多個target好多共用的工程。
第二個 就是產生的entitlements檔案要包含到bundle中
適配字型
ios中適配sb中的文本... 最好的辦法就是手動變更frame
純程式碼的頁面可以在計算字型size的時候根據比例添加一些frame
+(CGSize)textFrameWithString:(NSString *)text width:(float)width fontSize:(NSInteger)fontSize{ NSDictionary *dict = @{NSFontAttributeName: [UIFont systemFontOfSize:fontSize]}; // 根據第一個參數的常值內容,使用280*float最大值的大小,使用系統14號字,返回一個真實的frame size : (280*xxx)!! CGRect frame = [text boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil]; CGSize textSize = frame.size; CGFloat scale = 17.5/17.0; // iOS 10 if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) { textSize.width = textSize.width * scale; textSize.height = textSize.height * scale; } return textSize;}
iOS10好多坑 大家慢慢趟過去。