开发中 ios 11.0系统遇到的坑及解决办法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/JennyHermes/article/details/78437041
导读: 之前更新iOS11.0系统后,发现原来的项目有很多变化,例如,app的图标不显示了,tableview的布局变了,搜索框的样式也有所变化,因此,针对这些问题找到了相应的解决方案。

一、app的图标不显示

原因:图标不显示主要是cocoaPod出现了问题
解决方案:使用命令行

第一步在PodFile中添加

post_install do |installer|
copy_pods_resources_path = “Pods/Target Support Files/Pods-项目名/Pods-项目名-resources.sh”
string_to_replace = ‘–compile “ BUILTPRODUCTSDIR/ {UNLOCALIZED_RESOURCES_FOLDER_PATH}”’
assets_compile_with_app_icon_arguments = ‘–compile “ BUILTPRODUCTSDIR/ {UNLOCALIZED_RESOURCES_FOLDER_PATH}” –app-icon “ ASSETCATALOGCOMPILERAPPICONNAME"outputpartialinfoplist" {BUILD_DIR}/assetcatalog_generated_info.plist”’
text = File.read(copy_pods_resources_path)
new_contents = text.gsub(string_to_replace, assets_compile_with_app_icon_arguments)
File.open(copy_pods_resources_path, “w”) {|file| file.puts new_contents }
end

注意end不可缺,这end并不是PodFile中的end。 编辑完成后。执行pod install

第二步 修改resources.sh文件

这里写图片描述
打开resources.sh文件 将下面的printf代码替换为下面的代码

printf “%s\0” “ XCASSETFILES[@]"|xargs0xcrunactooloutputformathumanreadabletextnoticeswarningsplatform" {PLATFORM_NAME}” –minimum-deployment-target “ !DEPLOYMENTTARGETSETTINGNAME" {TARGET_DEVICE_ARGS} –compress-pngs –compile “ BUILTPRODUCTSDIR/ {UNLOCALIZED_RESOURCES_FOLDER_PATH}” –app-icon “ ASSETCATALOGCOMPILERAPPICONNAME"outputpartialinfoplist" {BUILD_DIR}/assetcatalog_generated_info.plist”

重启项目,处理完成

二、tableview因为分组导致距离顶部有空白

解决方案:

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.01;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}

注意:这里前2个代理返回的高度只能是0.01,不能设置为0,设置为0无效。

三、tableview刷新后页面“乱跑”

这是由于系统更新后,项目中没有使用estimateRowHeight属性

在appdelegate.m文件中,加上这几句代码:

//可以通过以下方式禁用

if (@available(iOS 11.0, *)) {

UITableView.appearance.estimatedRowHeight = 0;
UITableView.appearance.estimatedSectionFooterHeight = 0;
UITableView.appearance.estimatedSectionHeaderHeight = 0;
}

四、UISearchController的搜索框文字与图标居左显示

这里写图片描述

iOS11.0之前的搜索框文字和图标默认居中显示,更新后就变成上图。

不考虑重写的方法下

//加上这三句话
   UIOffset offset = {THfloat(90),0};
    _searchVC.searchBar.searchTextPositionAdjustment = offset;
    self.definesPresentationContext = YES;

可以达到这种效果:这里写图片描述

但是图标的位置我暂时还不知道如何更改。

五、高德地图不显示权限管理弹框

这里写图片描述

猜你喜欢

转载自blog.csdn.net/JennyHermes/article/details/78437041