I've searched for solutions to this problem but couldn't find anything that seems to address it in my case. I'm getting the above exception from a UITapGestureRecognizer.
Here's the simplified code:
import UIKit;
class ViewController : UIViewController, UIScrollViewDelegate
{
@IBOutlet weak var scrollView:UIScrollView!;
var imageView:UIImageView!;
override func viewDidLoad()
{
super.viewDidLoad();
... set up imageView/scrollView here ...
let doubleTapRecognizer = UITapGestureRecognizer(target: self, action: "onScrollViewDoubleTapped");
doubleTapRecognizer.numberOfTapsRequired = 2;
doubleTapRecognizer.numberOfTouchesRequired = 1;
scrollView.addGestureRecognizer(doubleTapRecognizer);
}
func onScrollViewDoubleTapped(recognizer:UITapGestureRecognizer)
{
}
}
Can anyone tell what is wrong with this code? It seems all correct to me. I suspect that it has to do with assigning ViewController as delegate to scrollView (or vice versa)? However the ViewController is set as the delegate to scrollView. But maybe it's something else that causes this error?
Try adding a colon to your selector string.
let doubleTapRecognizer = UITapGestureRecognizer(target: self, action: "onScrollViewDoubleTapped:");
As cabellicar123 mentioned, this indicates that the selector takes an argument.