So I have a UIBarButtonItem that I put on a screen via Storyboard. When I click on it, the screen should go to another view. This works fine. I also want to do some processing when the user clicks on the button. I’ve linked the button with the view controller and under “Sent Actions” selected the function I want to run when the button is pressed.
Normally, I would use IB to select Touch Up Inside and select the action there but I can’t find that anywhere (it’s also the first time I use a UIBarButtonItem so I don’t even know if that is an option here or not).
I guess the main question is: how do I link a UIBarButtonItem to a function so that when the user clicks on it, the application runs that function and then moves on to the next view? All of this in XCode 4.2…
EDIT: Bit of a typo there – meant UIBarButtonItem not UITabBarButton – been a long day!
Thanks,
If the button will always take you to the next view (that is, there is no validation that needs to be performed on the current view before you can leave) then you can call your function from
prepareForSegue:. Usesegue.identifierto work out which segue you are dealing with.