ios 更新适配问题持续更新一

2018-06-20  本文已影响0人  哈灰色

前言

部分ios 遇到的版本问题

问题和解决方法

1.联系人中空格问题

-(void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperty:(CNContactProperty *)contactProperty{
    if ([contactProperty.key isEqualToString:@"phoneNumbers"]) {
        CNPhoneNumber *phonenumber=contactProperty.value;//将value转为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:@"联系方式不是手机号"];
              }
    }
    else if ([contactProperty.key isEqualToString:@"postalAddresses"])
    {
        CNPostalAddress *address=contactProperty.value;
        NSLog(@"%@",address.street);
    }
    else
    {
        NSLog(@"%@",contactProperty.value);
    }
   
}

在处理phoneNumber多处理了一次;去掉空格的操作,在ios 11之后联系人中填写多个电话的时候就会出现出现格式不一样的空格,目前只能这么删除。个人建议用正则提取数据的方式提取数据。

2.选择手机联系人崩溃问题

9之前用

   ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
            peoplePicker.peoplePickerDelegate = self;
            [self presentViewController:peoplePicker animated:YES completion:^{
                [self dismiss];
            }];

9之后用

    // 1.创建选择联系人的控制器
    CNContactPickerViewController *contactVc = [[CNContactPickerViewController alloc] init];
    // 2.设置代理
    contactVc.delegate = self;
    // 3.弹出控制器
    [self presentViewController:contactVc animated:YES completion:nil];

3.UIViewView参数中文问题

项目中有一个打开三方url功能

window.location='你的url';

希望有更好的方式

4.ios10之后推送问题

  //如果要在iOS10显示交互式的通知,必须注意实现以下代码
    if ([[[UIDevice currentDevice] systemVersion]intValue]>=10) {
        UNNotificationAction *action1_ios10 = [UNNotificationAction actionWithIdentifier:@"action1_ios10_identifier" title:@"打开应用" options:UNNotificationActionOptionForeground];
        UNNotificationAction *action2_ios10 = [UNNotificationAction actionWithIdentifier:@"action2_ios10_identifier" title:@"忽略" options:UNNotificationActionOptionForeground];
        
        //UNNotificationCategoryOptionNone
        //UNNotificationCategoryOptionCustomDismissAction  清除通知被触发会走通知的代理方法
        //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];
    }
上一篇下一篇

猜你喜欢

热点阅读