iOS10 App適配許可權 Push Notifications 字型Frame 遇到的坑!!!!,ios10notifications

來源:互聯網
上載者:User

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好多坑 大家慢慢趟過去。

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.