swift
1 override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent){ 2 3 super.touchesBegan(touches, with: event) 4 5 let touch: UITouch = touches.first as! UITouch 6 7 if touch.view == UIButton{ 8 print("あたり") 9 }else if touch.view == largeImageView{ 10 print("外れ") 11 } 12 }
largeImageViewというimageViewのなかでuibuttonならあたりと表示させ、それ以外の画面をタップした場合は外れと表示させたいです。
しかしMethod does not override any method from its superclass、Binary operator '==' cannot be applied to operands of type 'UIView?' and 'UIButton.Type'という二つのエラーが出ます。どこがおかしいのでしょうか。よろしくお願いします。
あなたの回答
tips
プレビュー