標籤:services 方式 企業 開啟 cti ios 開發 cat crash alert
1、使用%zd列印NSInteger ,%tu列印NSUInteger
2、UIScrollView在iOS7中使用了Autolayout導致不能滾動,方法是添加scrollview的content高度
3、UICollectionView的資料不夠,無法滑動,解決方案:tableview的資料無論多少,它的介面預設都是可以滑動的,和tableview相比collectionview的資料較少不夠一個螢幕是它無法滑動collectionview.alwaysBounceVertical=YES;設定總能垂直滑動就行。
4、直接ios7的連續跳轉
-(void)back
{
[self dismissViewControllerAnimated:YES completion:^{
if([weakself.navigationController popViewControllerAnimated:YES]){
}
}];
}
5、ios8以後用WKWebView代替UIWebView,ios8之前使用UIWebView進行html的展示,使用UIWebView存在記憶體佔用過大並不釋放問題。WKWebView解決記憶體佔用過大問題
6、企業認證下載版本可在APP中直接開啟,在APP中有H5的頁面,可以直接點擊進行其他應用的下載
7、URL轉碼問題,
stringByAddingPercentEscapesUsingEncoding,ios9版本中需要使用
stringByAddingPercentEncodingWithAllowedCharacters替代之前stringByAddingPercentEscapesUsingEncoding。
8、iOS 開發,工程中混合使用 ARC 和非ARC
Xcode 項目中我們可以使用 ARC 和非 ARC 的混合模式。
如果你的項目使用的非 ARC 模式,則為 ARC 模式的代碼檔案加入 -fobjc-arc 標籤。
如果你的項目使用的是 ARC 模式,則為非 ARC 模式的代碼檔案加入 -fno-objc-arc 標籤。
添加標籤的方法:開啟:你的target -> Build Phases -> Compile Sources 2、雙擊對應的 *.m 檔案 3、在快顯視窗中輸入上面提到的標籤 -fobjc-arc / -fno-objc-arc 4、點擊 done 儲存
9、
分享的時候注意大小
text 的大小必須 大於0 小於 10k
image 必須 小於 64k
url 必須 大於 0k
10、APNS推送
推送的 pem 檔案的產生:
pem 認證是伺服器向蘋果伺服器做推送時候需要的檔案。
Apple Development Push Services > Export “Apple Development Push Services ID123”,儲存為 apns-dev-cert.p12。 對“Private Key”做同樣操作,儲存為 apns-dev-key.p12 檔案。
? 需要通過終端命令將這些檔案轉換為 PEM 格式:
openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -inapns-dev-cert.p12
openssl pkcs12 -nocerts -out apns-dev-key.pem -inapns-dev-key.p12
此處要求輸入一個密碼,輸入 123456.
移除密碼(上面的 123456)
openssl rsa -in apns-dev-key.pem -out apns-dev-key.pem
最後,你需要將鍵和許可檔案合成為 apns-dev.pem 檔案,此檔案在串連到 APNS 時需要使用:
cat apns-dev-cert.pem apns-dev-key.pem > apns-dev.pem
同樣 Distribution Certificate 的 pem 檔案產生方式一樣。
openssl pkcs12 -clcerts -nokeys -out apns-dis-cert.pem -inapns-dis-cert.p12
openssl pkcs12 -nocerts -out apns-dis-key.pem -in apns-dis-key.p12openssl rsa -in apns-dis-key.pem -out apns-dis-key.pem
cat apns-dis-cert.pem apns-dis-key.pem > apns-dis.pem
// IOS8 新系統需要使用新的代碼咯
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings
settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)
categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
//這裡還是原來的代碼
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
原本在IOS7當中 判斷PUSH是否開啟的方法是:
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
return (types & UIRemoteNotificationTypeAlert);
如果將這段代碼使用在 IOS當中,雖然不會出現crash的現象,但是基本沒什麼作用。
在IOS8中,我們使用如下的新代碼來取代以上的代碼
{
UIRemoteNotificationType types;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
}
else
{
types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
}
return (types & UIRemoteNotificationTypeAlert);
}
iOS開發經驗總結一