我无法设置'已启用'具有手势识别器的属性。我尝试以编程方式创建识别器,并在@IBAction
中添加Xcode
并通过控制拖动将其连接到代码。
我尝试使用这样的属性:
swipeUpOccurred(swipeUp: UISwipeGestureRecognizer).enabled = false
但它显示错误:
类型的价值'(UISwipeGestureRecognizer) - >'没有会员'已启用'
答案 0 :(得分:4)
您正尝试在UIGestureRecognizer
的操作上设置isEnabled
。如果您想在UIGestureRecognizer
内访问它,则需要创建ViewController
的Outlet,因此请使用其特定类型创建该手势的一个Outlet,然后将isEnabled
属性设置为{ {1}}当你需要true/false
时。{/ p>
enable/disabled
现在使用@IBOutlet var swipeGest: UISwipeGestureRecognizer!
属性。
isEnabled
答案 1 :(得分:0)
它被重命名。请改为isEnabled
。
swipeUpOccurred(swipeUp: UISwipeGestureRecognizer).isEnabled = false
答案 2 :(得分:0)