1

I am using storyboard and I have 2 custom views in them.

Now if i have a button on the main View then I am able to move the embedded views, but if the buttons are on the custom views I cannot get the same effect. Yes I can move the view of the View Controller I am on, but I cannot control the action of the parent controller.

Is that out of the question or am I looking at this the wrong way?

Please observe the image and I will explain what I am trying to achieve:

My Storyboard

Please note I have seen this question :Passing an IBAction to another ViewController This does not seem to work in my setup.

Ok, so Main Right and Main Left work as expected - they shift the Right SideVC to the right and reveal the left and back.

Now I want those behavior to take place on the Right Side VC and the Left Side VC, because I want to remove the Main Right and Main Left button.

Community
  • 1
  • 1
jwknz
  • 6,598
  • 16
  • 72
  • 115
  • Why people use the term "IBAction" all the time? There's no such thing as "an IBAction". There are *actions,* there are *methods returning a value of type `IBAction`,* etc. Please use terminology correctly. –  Nov 21 '12 at 22:10
  • 2
    I am so sorry it is a matter of annoyance to you - then again, I only see you complain on other questions, so I am not so fussed about it:-) – jwknz Nov 21 '12 at 22:20
  • I'm not only complaining because it's annoying but mostly because it's confusing. I didn't want by any means to harras anyone, but everybody should use correct wording here, because not doing so makes hard understanding what the problem is. –  Nov 21 '12 at 22:22
  • 1
    True - but does that make you the better programmer if you can understand other people "jargon" using the proper terminology is important, but also a learning curve:-) – jwknz Nov 21 '12 at 22:23

2 Answers2

0

The IBAction are simply void type of method which does not returns anything. The name IBAction is placed just to make it simple to connect the interfaces. So, it is similar to other method. As long as the object is around (viewcontroller in this case) exists you can call any method that it responds to.

Sandeep
  • 20,908
  • 7
  • 66
  • 106
-1

So I was able to solve my problem by using the AppDelegate. I have read in a few articles it is not always the best place to put stuff, but for this I think it is ok:-)

-(IBAction)move03
 {
    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    MainViewController* viewController = appDelegate.viewController;
    [_move01Button addTarget:viewController action:@selector(move01Action) forControlEvents:UIControlEventTouchUpInside];
 }
jwknz
  • 6,598
  • 16
  • 72
  • 115
  • Breaking design patterns to gain this functionality is a slippery slope, I'm frequently running into people needing fixes on old projects with AppDelegates containing thousands of lines of code. – Stu P. Jan 14 '14 at 16:48