When I ctrl-drag from a UIButton
in storyboard to the viewcontroller class,
Xcode is not showing the option to create an IBAction.
I have already tried to start a new project and it still does not have the Connect: Action option available.
When I ctrl-drag from a UIButton
in storyboard to the viewcontroller class,
Xcode is not showing the option to create an IBAction.
I have already tried to start a new project and it still does not have the Connect: Action option available.
Please follow below steps :-
storyboard
and yourViewController
side by side after clicking on Assistant Editor. UIButton
to class
file. It will open one popup menu. @IBAction
connection.Hope above steps is useful for you.
Check that the ViewController cocoa class is correctly connected to the ViewController in the Interface builder, then,try with this answer: https://stackoverflow.com/a/37322981/8038084.
Sometimes, even restarting and cleaning does not help me. What I do is make it the other way round.
Create an IBAction
manually in your code.
@IBAction func buttonPressed() {
[...]
}
The function should appear inside your IB under Connections inspector/Received Actions...
where you can simply connect it to your button/gesture recognizer etc.