0

I'm using ECSliding and I have this problem!

I have a topView and two menus,

left (LeftViewController) 
right (RightViewController)

both UIViewController.

I want to give a reference to the right view controller, to the left view controller, in the AppDelegate.

I did in LeftViewController.h:

#import "RightViewController.h"
@class RightViewController;
@property (strong, monatomic) RightViewController *rightView;

in didFinishLaunchingWithOptions in AppDelegate.m :

RightViewController *rightViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Right"];
LeftViewController *leftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Left"];

leftViewController.rightView = rightViewController;

but I get this error in AppDelegate.m on self.storyboard:

Property 'storyboard not found on object of type 'AppDelegate *

How can I solve this problem?

Tortuga
  • 97
  • 3
  • 10
  • @CodeMonkey the question was for other error:)) A view controller wasn't recognized by the compiler :) – danypata Jun 03 '13 at 20:15
  • Try looking at the ecslidingmenu menu code. The storyboard can't be referenced like that in app delegate. Try declaring the storyboard and then instantiating the view controller with the storyboard id. – Adrian P Jun 03 '13 at 20:17
  • @danypata I think you are referring to my other question, I solved adding `@class RightViewController;` – Tortuga Jun 03 '13 at 20:33

2 Answers2

0

First of all AppDelegate doesn't have a property storyboard it's a UIViewController property.

Second if you want to load the main storyboard and instantiate a view controller you should try the following:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"YourStoryboardName" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"YourViewController"];

Also make sure you properly set the view controllers identifier.

danypata
  • 9,895
  • 1
  • 31
  • 44
  • I have two storyboards, what I have to put in the (?) `UIStoryboard *sb = [UIStoryboard (?) bundle:nil];` ? – Tortuga Jun 03 '13 at 20:25
  • You will have to load the storyboard that has the `RightViewController ` and the `LeftViewController` declared in. – danypata Jun 03 '13 at 20:27
  • both storyboards have both controllers, in `didFinishLaunchingWithOptions` the first thing I do is `[self initializeStoryBoardBasedOnScreenSize]` – Tortuga Jun 03 '13 at 20:30
  • @user2349568 I googled `initializeStoryBoardBasedOnScreenSize` and it showed that the SO user used this method to load different storyboards based on screen size. Is this what you are doing ? – danypata Jun 03 '13 at 20:32
  • Well then, you have to load the same storyboard that is loaded in that method, or you can instantiate your view controllers in that method. – danypata Jun 03 '13 at 20:36
0

Don't statically give them a reference to each other. Instead, when they are part of the sliding view controller self.slidingViewController will be a valid reference and you can navigate based on the relationships that actually exist:

self.slidingViewController.underLeftViewController

When using it, you should check the class and cast the reference:

LeftViewController *leftController = self.slidingViewController.underLeftViewController;

if ([leftController isKindOfClass:[LeftViewController class]]) {
    leftController. ...;
}
Wain
  • 118,658
  • 15
  • 128
  • 151
  • I need the reference to call in `LeftViewController` a timer that is in `RightViewController`, using `self.slidingViewController.underLeftViewController.(?)` nothing appera at (?) – Tortuga Jun 03 '13 at 20:27