【发布时间】:2020-01-20 14:04:46
【问题描述】:
我创建了一个自定义下拉列表,它是 UIButtons 的堆栈视图。并制作了 UIlabel 文本(服务条款)的可点击部分。 两者都在 iphone XR 上完美运行(可以点击它们)。
该问题仅出现在较小的设备上(iphone 6,7)。下拉列表中的最后一个 UIButton 可在按钮标题上方点击,而不是在标签或整个按钮空间上。 UILabel(服务条款)是完全不可点击的。 Iphone XR 运行良好。
监听 UILabel tap(在较小的设备上不调用):
@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 overview
布局约束日志,当我打开一个下拉列表时:
"<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)>
任何想法,这种行为的原因可能是什么?非常感谢。
【问题讨论】:
标签: ios swift xcode interface-builder