iOS 11 适配笔记

来源:互联网 发布:易语言传奇辅助源码 编辑:程序博客网 时间:2024/06/06 10:48

一、定位权限:

无论是iOS11还是之前的系统版本,定位权限总共就三种:“永不”、“使用应用期间”、“始终”
之前的iOS 10的定位权限是

Privacy - Location Always Usage Description //始终Privacy - Location Usage Description    //允许定位Privacy - Location When In Use Usage Description    //使用应用期间

iOS11后增加了一种定位权限,而且要求必须使用此权限才能使用定位服务

Privacy - Location Always and When In Use Usage Description

当大家升级到Xcode9后,会发现设置的iOS10之前的定位权限,在iOS11的项目上无法使用定位服务了,
为了适配iOS11的定位权限,大家只需在工程的info.plist文件里添加以下权限key value就行了

Privacy - Location When In Use Usage DescriptionPrivacy - Location Always and When In Use Usage Description

iOS10的定位权限
这里写图片描述
iOS11的定位权限
这里写图片描述

二、跳转到App Store:

一般我们的app跳转到app store里需求无外乎两种:一种是引导用户下载某个app;一种是引导用户对某个app做评价。
iOS11的App Store进行了大改版,之前的跳转到App Store里引导用户对app做评价的页面在iOS10里是一个单独的页面,我们也可一跳转到这个评价页面,但是iOS11的评价是在app详情的首页的,所以导致之前到跳转到app评价页面的URL在iOS11里就不管用了。
解决办法是做个判断,iOS10之前的系统版本都跳转到app评价页面,iOS11跳转到app详情页面。
跳转到app store里某个app对应的详情页面的URL有如下两种:

[NSString stringWithFormat:@"https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=%@&mt=8", kAppId][NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@", kAppId]

iOS10之前跳转到app store里某个app对应的评价页面的URL如下:

[NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@&pageNumber=0&sortOrdering=2&mt=8", kAppId]

所以iOS11之后跳转到App Store里对app评价,可以写成如下宏定义:

///app store 评论URL#define kAppStoreComment    ( (IOSVersion<=10)?[NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@&pageNumber=0&sortOrdering=2&mt=8", kAppId] : [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@", kAppId])

其中 IOSVersion 是个宏定义

//系统版本号#define IOSVersion          [[[UIDevice currentDevice] systemVersion] floatValue]

三、tableview的footer view问题:

在iOS10之前的系统显示页面如下:
这里写图片描述
iOS11系统上显示的页面如下:
这里写图片描述
之所以在iOS11上出现这样的显示效果是因为没有实现

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

这个方法。这说明了在iOS10之前的系统上可能系统默认实现了
viewForFooterInSection
方法,而iOS11系统没有默认实现,必须开发者实现,所以iOS11上一定要实现如下delegate方法:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
原创粉丝点击