【发布时间】:2016-12-14 23:09:41
【问题描述】:
我有以下看法:
它的构建方式
UIViewController --> UIView(底部方块)--> UIViewController(加载在底部方块中)
此 UIViewController 中的按钮按下不会被触发。但是,当我在模拟器中按下时,我确实看到了按钮动画。
此外,当我以编程方式将以下点击处理程序添加到此 UIViewController 中的圆形 UIImageView 时,它会响应:
func handleTap(sender: UITapGestureRecognizer? = nil) {
print("tappable")
}
let tap = UITapGestureRecognizer(target: self, action: #selector(NeighbourhoodViewController.handleTap(_:)))
userPopupView.userImageView.userInteractionEnabled = true
userPopupView.userImageView.addGestureRecognizer(tap)
如何捕捉对这些按钮的操作?这不起作用:
@IBAction func test(sender: AnyObject) {
print("test")
}
顺便说一句,该线连接到界面生成器中的 UIButton:
【问题讨论】:
-
在相关按钮或视图上启用了用户交互?
-
是的,用户交互无处不在。在 UIView 上。在 UIViewController 上。在 UIButton 上。按钮还会显示动画(按下时突出显示等),表示接收到触摸。
-
这个“测试”方法是唯一链接到按钮插座的东西吗?查看 IB 中的 outlets 选项卡,确认没有冲突。
-
添加了另一张图片。
-
我一无所获...有兴趣知道这个问题的解决方案。
标签: ios iphone swift uiviewcontroller uibutton