ios - Is there is UITapGesture size limit between regular and plus sized iPhones
问题描述
I am adding a UITapGesture to a UILabel in my code. What is confusing me, when I run the code on an iPhone 7/8 on Hardware or in the Simulator, the TapGesture isn't called. However if I run the exact same code on an iPhone 7/8 PLUS on Hardware or in the Simulator the UITapGesture is fired.
Is there some sort of size limit to touch sizes which is causing this, and how do I get around it?
I have double checked the User Interaction is selected in Xcode.
let myTap = UITapGestureRecognizer(target: self, action: #selector(myAction))
myLabel.addGestureRecognizer(myTap)
This is how I am adding the tap.
解决方案
DonMag、Matt 和 Michael 最后都成为了获胜者。
好的,基本上我的视图位于堆栈视图的一部分中。
基本上,自动布局没有调整包含所有具有 GestureRecognizers 的子视图的超级视图的高度。所以即使标签仍然可见,他们也没有收到手势,因为他们超出了父母的范围。但奇怪的是,这只发生在 7 和 8 以及 7 Plus 和 8 Plus 上。所以基本上添加了一个约束来将容器视图的高度设置为等于堆栈视图的高度(强制 Autolayout 为 7/8 重新调整所有内容,这似乎可以解决问题)。
超级烦人,但是感谢您的建议,不胜感激。
在 7 中切换到视图情节提要也很有帮助。
推荐阅读
- azure - 拆分逗号分隔的字符串
- java - 如何在 kotlin 中首次构建 Room 数据库时修复异常
- eclipse - 如何使用 jbehave 在 Eclipse 上运行 sikuli 脚本?
- file - 在没有名为“Desktop.ini”的文件的情况下使用 Fossil 更新到以前版本的代码
- javascript - 如何在反应表中使用 getTheadThProps?
- c# - 将抓取页面的内容写入文本文件以在客户端浏览器上下载
- asp.net-mvc - 在 ASP.NET MVC 中将 ViewModel 与多个模型一起使用
- java - 如何使 Environment.getExternalStoragePublicDirectory() 创建到 SD 卡的路径,而不是 emulated/0 内部存储器?
- python - Twython - 获取最新的直接消息
- c# - .NET Core 2.x Identity int 外键无法定位 int 主键