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

本文详细介绍了在iOS 11.0系统中遇到的五大开发问题,包括app图标不显示、tableview分组间距、tableview刷新后布局、UISearchController搜索框样式以及高德地图权限弹框缺失的解决方法。通过修改PodFile、resources.sh文件以及调整代码实现修复。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

导读: 之前更新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;

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

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

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

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值