I have an IBAction button in one UIViewController that I want to perform an action in another UIViewController. How do I do this?
Asked
Active
Viewed 1,669 times
1 Answers
1
Declare a method in the second UIViewController and call from the IBAction in the first controller.
Something like this:
-(IBAction)myMethodFromFirstController{
SecondController *secondController = [[SecondController alloc] init];
[secondController method];
}

alexandresoli
- 918
- 1
- 9
- 18
-
How would the method look like in second view controller? – TWcode Oct 06 '12 at 20:52
-
I am getting an error no visible interface: -(IBAction)myMethodFromFirstController{ PhoneMainV *secondController = [[PhoneMainV alloc] init]; [secondController myMethodFromFirstController]; } – TWcode Oct 07 '12 at 15:46
-
I think you need to read about the basics of viewcontrollers, i recommend the big nerd ranch guide. Anyways, you can get a full tutorial from here. http://www.ifans.com/forums/threads/tutorial-how-to-set-the-view-and-how-to-switch-between-2-views.191002/ – alexandresoli Oct 07 '12 at 20:41