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?
11
-
show your tried codeAnbu.Karthik– Anbu.Karthik2017-06-07 04:47:11 +00:00Commented 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.szeto1121– szeto11212017-06-07 04:49:43 +00:00Commented Jun 7, 2017 at 4:49
-
eg : func menuButtonPressed(){ print("ABC") }szeto1121– szeto11212017-06-07 04:49:52 +00:00Commented Jun 7, 2017 at 4:49
-
directly you can use drag and drop the functionsAnbu.Karthik– Anbu.Karthik2017-06-07 04:50:18 +00:00Commented Jun 7, 2017 at 4:50
-
just make an IBAction of that button.Usman Javed– Usman Javed2017-06-07 04:50:52 +00:00Commented Jun 7, 2017 at 4:50
|
Show 6 more comments
1 Answer
You can create IBAction for the barbutton item in storyboard like this
OR
Create a function like this and connect with bar button item
3 Comments
szeto1121
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
RajeshKumar R
May be you were trying to create action in another view controller class.
szeto1121
While I am just assigning a function to that button like what you did, it is not clickable as well


