前言
部分ios 遇到的版本問題
問題和解決方法
1.聯(lián)系人中空格問題
-(void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperty:(CNContactProperty *)contactProperty{
if ([contactProperty.key isEqualToString:@"phoneNumbers"]) {
CNPhoneNumber *phonenumber=contactProperty.value;//將value轉(zhuǎn)為cnphonenumber類型
NSLog(@"%@",phonenumber.stringValue);
NSString *phoneNumber = phonenumber.stringValue;
phoneNumber= [phoneNumber stringByReplacingOccurrencesOfString:@"-" withString:@""];
phoneNumber= [phoneNumber stringByReplacingOccurrencesOfString:@"+86" withString:@""];
phoneNumber= [phoneNumber stringByReplacingOccurrencesOfString:@" " withString:@""];
phoneNumber= [phoneNumber stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString *str=[NSString stringWithFormat:@"%@ %@",contactProperty.contact.familyName,contactProperty.contact.givenName];
if ([phoneNumber isTelephone:phoneNumber]) {
self.phoneTextField.text = [NSString formatPhoneToThreeParagraph:phoneNumber];
self.nameTextField.text = str;
}else{
[self failString:@"聯(lián)系方式不是手機號"];
}
}
else if ([contactProperty.key isEqualToString:@"postalAddresses"])
{
CNPostalAddress *address=contactProperty.value;
NSLog(@"%@",address.street);
}
else
{
NSLog(@"%@",contactProperty.value);
}
}
在處理phoneNumber多處理了一次;去掉空格的操作凡傅,在ios 11之后聯(lián)系人中填寫多個電話的時候就會出現(xiàn)出現(xiàn)格式不一樣的空格滞磺,目前只能這么刪除阁将。個人建議用正則提取數(shù)據(jù)的方式提取數(shù)據(jù)尤勋。
2.選擇手機聯(lián)系人崩潰問題
9之前用
ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
peoplePicker.peoplePickerDelegate = self;
[self presentViewController:peoplePicker animated:YES completion:^{
[self dismiss];
}];
9之后用
// 1.創(chuàng)建選擇聯(lián)系人的控制器
CNContactPickerViewController *contactVc = [[CNContactPickerViewController alloc] init];
// 2.設(shè)置代理
contactVc.delegate = self;
// 3.彈出控制器
[self presentViewController:contactVc animated:YES completion:nil];
3.UIViewView參數(shù)中文問題
項目中有一個打開三方url功能
- 含有中文參數(shù)url
- 已經(jīng)編碼過參數(shù)url
解決辦法:這種問題基本上不管你編碼不管你轉(zhuǎn)碼還是不轉(zhuǎn)碼都會有一方無法訪問;目前我采用的是自己寫的界面里面做跳轉(zhuǎn)這樣程序
window.location='你的url';
希望有更好的方式
4.ios10之后推送問題
//如果要在iOS10顯示交互式的通知规伐,必須注意實現(xiàn)以下代碼
if ([[[UIDevice currentDevice] systemVersion]intValue]>=10) {
UNNotificationAction *action1_ios10 = [UNNotificationAction actionWithIdentifier:@"action1_ios10_identifier" title:@"打開應(yīng)用" options:UNNotificationActionOptionForeground];
UNNotificationAction *action2_ios10 = [UNNotificationAction actionWithIdentifier:@"action2_ios10_identifier" title:@"忽略" options:UNNotificationActionOptionForeground];
//UNNotificationCategoryOptionNone
//UNNotificationCategoryOptionCustomDismissAction 清除通知被觸發(fā)會走通知的代理方法
//UNNotificationCategoryOptionAllowInCarPlay 適用于行車模式
UNNotificationCategory *category1_ios10 = [UNNotificationCategory categoryWithIdentifier:@"category101" actions:@[action1_ios10,action2_ios10] intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
NSSet *categories_ios10 = [NSSet setWithObjects:category1_ios10, nil];
[center setNotificationCategories:categories_ios10];
}else
{
[UMessage registerForRemoteNotifications:categories];
}