我只是将iOS开发作为Android开发人员。在Android中,除了Gesture Recognizer之外,我都可以在iOS上很难找到的任何视图上设置clicklistener。我想在视图上设置手势识别器,以从一个视图控制器导航到另一个视图控制器。我可以指导吗
override func viewDidLoad() {
initiateTapGestures(view: circleView, action: #selector(self.tapDetectedForProfile))
}
func initiateTapGestures(view:UIView, action:Selector?){
let singleTap = UITapGestureRecognizer(target: self, action: action)
view.isUserInteractionEnabled = true
view.addGestureRecognizer(singleTap)
}
@objc func tapDetectedForProfile(){
print("profile setting")
let profile = ProfileViewController()
self.navigationController?.pushViewController(ProfileViewController(), animated: false)
}
override func viewDidLoad() {
super.viewDidLoad()
circle.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didClickedView(_ :))))
}
@objc func didClickedView(_ sender : UITapGestureRecognizer){
print("profile setting")
let profile = ProfileViewController()
self.navigationController?.pushViewController(ProfileViewController(), animated: false)
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句