1

I have used a tool bar on the storyboard and i have some custom buttons on it. How can I assign these buttons to the functions created in the Viewcontroller?

enter image description here

11
  • show your tried code Commented Jun 7, 2017 at 4:47
  • the buttons are created through storyboard. and I do not know how to assign those buttons to specific functions. Commented Jun 7, 2017 at 4:49
  • eg : func menuButtonPressed(){ print("ABC") } Commented Jun 7, 2017 at 4:49
  • directly you can use drag and drop the functions Commented Jun 7, 2017 at 4:50
  • just make an IBAction of that button. Commented Jun 7, 2017 at 4:50

1 Answer 1

2

You can create IBAction for the barbutton item in storyboard like this

IBAction for UIBarButtonItem

OR

Create a function like this and connect with bar button item

IBAction for UIBarButtonItem

Sign up to request clarification or add additional context in comments.

3 Comments

i have no idea why the button in my original project is not clickable but when i created a new project with the buttons, they are clickable
May be you were trying to create action in another view controller class.
While I am just assigning a function to that button like what you did, it is not clickable as well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.