Client error attempting to change layout margins of a private view
从 iOS 11 开始,UINavigationBar 使用了自动布局,左右两边的按钮到屏幕之间会有 16 或 20 的边距。
为了避免点击到间距的空白处没有响应,通常做法是:定义一个 UINavigationBar 子类,重写 layoutSubviews 方法,在此方法里遍历 subviews 获取 _UINavigationBarContentView,并将其 layoutMargins 设置为 UIEdgeInsetsZero。
- (void)layoutSubviews {
[super layoutSubviews];
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) containsString:@"_UINavigationBarContentView"]) {
subview.layoutMargins = UIEdgeInsetsZero;
break;
}
}
}
然而,这种做法在 iOS 13 中会导致崩溃,崩溃信息如下:
Client error attempting to change layout margins of a private view
试图更改私有视图的布局边距时出现错误
解决方案:
使用设置 frame 的方式,让 _UINavigationBarContentView 向两边伸展,从而抵消两边的边距
- (void)layoutSubviews {
[super layoutSubviews];
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) containsString:@"_UINavigationBarContentView"]) {
if ([UIDevice currentDevice].systemVersion.floatValue >= 13.0) {
UIEdgeInsets margins = subview.layoutMargins;
subview.frame = CGRectMake(-margins.left, -margins.top, margins.left + margins.right + subview.frame.size.width, margins.top + margins.bottom + subview.frame.size.height);
} else {
subview.layoutMargins = UIEdgeInsetsZero;
}
break;
}
}
}
Client error attempting to change layout margins of a private view的更多相关文章
- 0xc000000f: Error attempting to read the boot configuration data
Get the fix to “0xc000000f: error attempting to read the boot configuration data” boot error for Win ...
- Mybatis使用-Error attempting to get column 'type' from result set. / '255' in column '4' is outside valid range for the datatype TINYINT.
一.遇到的问题是这样的: [RemoteTestNG] detected TestNG version 6.9.10log4j: Parsing for [root] with value=[DEBU ...
- Cisco VPN Client Error 56解决
Cisco VPN Client Error 56解决 VPN Client报错 650) this.width=650;" style="width:575px;height:1 ...
- org.springframework.jdbc.UncategorizedSQLException: Error attempting to get column 'alarmGroup' from result set. Cause: java.sql.SQLException: Error
异常展示: org.springframework.jdbc.UncategorizedSQLException: Error attempting to get column 'alarmGroup ...
- axis client error Bad envelope tag: definitions
http://blog.csdn.net/lifuxiangcaohui/article/details/8090503 ——————————————————————————————————————— ...
- docker升级后启动报错400 Client Error: Bad Request ("Unknown runtime specified docker-runc")
宝塔面板docker升级后启动容器时报错400 Client Error: Bad Request ("Unknown runtime specified docker-runc" ...
- Error attempting to get column from result set
当使用mybatis plus3.2.0+springboot2.1.1 报错 Error attempting to get column from result set 1.一般出现这种问题,最简 ...
- Hadoop启动错误——ERROR: Attempting to operate on hdfs namenode as root but there is no HDFS_NAMENODE_USER defined. Aborting operation.
错误如下所示; [root@localhost sbin]# start-all.sh Starting namenodes on [192.168.71.129] ERROR: Attempting ...
- hyper-v启动虚拟机时提示“The application encountered an error while attempting to change the state of the machine ‘虚拟机名称'”如何处理?
1. 找出发生这一问题的事件代号 1.1 在开始菜单中搜索程序Event Viewer并点击进入 1.2 点击路径如下: “Applications and Services Logs > Mi ...
随机推荐
- ES6面向对象实现tab栏切换效果
面向对象实现tab栏切换效果
- SpringMVC请求参数接收总结(一)
前提 在日常使用SpringMVC进行开发的时候,有可能遇到前端各种类型的请求参数,这里做一次相对全面的总结.SpringMVC中处理控制器参数的接口是HandlerMethodArgumentRes ...
- idea为什么maven工具栏下面没有dependencies跟Plugins
刚刚新建的springboot项目,然后进来就是这样子 网上查找资料有些说是maven版本的问题,但是对于我的问题并没有得到解决. 现在是2019年12月4日16:23:07,依然没有找到解决方法,不 ...
- djanao请求生命周期
djanao请求生命周期 浏览器发送请求到服务端 服务端的wsgi服务器接收到来自浏览器的请求, 对request做一些预处理, 把浏览器的请求信息(请求方式, 请求头, socket信息等)都封装在 ...
- Centos 7.x 系统基础优化
Centos 7.x 系统基础优化 1.更换国内yum源 删除系统带的centos官方yum源 rm -rf /etc/yum.repos.d/* 使用国内阿里云源 curl -o /etc/yum. ...
- c++关于multiset的头文件包含问题
最近在Bilibili上看到不少侯捷老师C++的视频教程,侯捷老师翻译了很多C++的经典书籍,比如<Essential C++中文版>.<STL源码剖析>,也写了<深入浅 ...
- Spring 之初识IOC和DI
下载Spring jar包 Spring官网 下载地址 Sping核心jar包 IOC简介 IOC:控制反转,指以前程序自己创建对象,现在将创建对象的控制权交给了第三方(Spring)了 IoC底层实 ...
- 【实用工具】使用Java封装可执行exe应用全过程
目录 编写java代码 打包 创建exe文件 压缩 总结 本文将使用exe4j将java项目封装为可以发送给他人使用的工具为例,来记录将java项目封装为exe文件的全过程 编写java代码 目标:创 ...
- python获取bing地图发布自己的TMS服务(一)下载瓦片
部分结果 bing地图瓦片使用QuadKey作为命名方式. QuadKey简介 如何计算quadkey 在给定level下,把行号tileY和列号tileX转换为2进制,然后行列交叉存储,再转换为4进 ...
- Binary Search Tree analog
Description Binary Search Tree, abbreviated as BST, is a kind of binary tree maintains the following ...