I know that there are already some questions about this, but I could not find a solution. There is very simple code that works great in one of my projects, but not on the other:
Here is the code for a subclass of UIView.
import UIKit class test : UIView { init(frame: CGRect, color: UIColor) { super.init(frame: frame) self.backgroundColor = color self.userInteractionEnabled = true } required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { super.touchesBegan(touches, withEvent: event) var alert = UIAlertView() alert.title = "lol" alert.message = "lol" alert.addButtonWithTitle("Ok") alert.show() } }
I am sure that the solution is quite simple, but I can not find it.
ios swift touchesbegan
La masse
source share