Reputation: 9389
I have the following view on my storyboard. I'm trying to create an IBAction on the Send button by dragging and dropping it on my View Controller. Unfortunately the action is not being called.
So my action looks like this:
@IBAction func sendMessage(sender: UIBarButtonItem) {
print("test")
}
What i also tried is to drag the bar item as an Outlet on my Controller and set the action programatically.
@IBOutlet weak var sendButton: UIBarButtonItem!
override func viewDidAppear(animated: Bool) {
self.sendButton.target = self;
self.sendButton.action = Selector("sendMessage:")
}
func sendMessage(sender: UIBarButtonItem) {
print("hue")
}
No log message is displayed. It just dont call the actions.
Upvotes: 0
Views: 1225
Reputation: 9389
Just figured it out.
I must drag the UIButton inside the UIBarButtonItem not the UIBarButtonItem. So as you can see in the image bellow i was dragging the Item Send Button
not the button Send
.
Upvotes: 2