我创建了一个自定义下拉列表,它是UIButtons的堆栈视图。并对UIlabel文本(服务条款)做了一个可移植的部分。这两款手机在iphone上都能完美地工作(可以点击它们)。
这个问题只发生在较小的设备上(iphone 6,7)。下拉列表中的最后一个UIButton可以在按钮标题的上方,而不是在标签上或整个按钮空间上。UILabel(服务条款)是完全不可移植的。Iphone运行得很好。
监听UILabel抽头(不在较小的设备上调用):
@objc func tapLabel(gesture: UITapGestureRecognizer) {
print("TapLabel")
let text = "By upgrading your account, you agree to our Terms of Service."
let termsRange = (text as NSString).range(of: "Terms of Service.")
if gesture.didTapAttributedTextInLabel(label: textTerms, inRange: termsRange) {
if let url = URL(string: "https://xxxxx/terms") {
UIApplication.shared.open(url)
}
} else {
print("Tapped none")
}
}Interface-builder: 接口概述
布局约束日志,当我打开下拉列表时:
"<NSLayoutConstraint:0x2823f4230 UIButton:0x109505a70'Quarterly Subscription - ...'.height == 50 (active)>",
"<NSLayoutConstraint:0x2823f5680 V:[UIButton:0x10950d760'Quarterly Subscription - ...']-(0)-[UIButton:0x109505a70'Quarterly Subscription - ...'] (active)>",
"<NSLayoutConstraint:0x2823f5a40 V:[UIButton:0x109505a70'Quarterly Subscription - ...']-(0)-[UIButton:0x10950d260'Monthly Subscription - 13...'] (active)>",
"<NSLayoutConstraint:0x2823f48c0 'UISV-spacing' V:[UIButton:0x10950d760'Quarterly Subscription - ...']-(0)-[UIButton:0x10950d260'Monthly Subscription - 13...'] (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x2823f4230 UIButton:0x109505a70'Quarterly Subscription - ...'.height == 50 (active)>任何想法,这种行为的原因是什么?非常感谢。
发布于 2019-09-19 14:00:12
您可能设置了相对于超级视图的标签/按钮的宽度和高度,因为它们的大小非常小,或者上面有其他视图。
https://stackoverflow.com/questions/58012682
复制相似问题