0

我正在使用 ECSliding,但我遇到了这个问题!

我有一个 topView 和两个菜单,

left (LeftViewController) 
right (RightViewController)

两者UIViewController

我想在 AppDelegate 中提供对右视图控制器、左视图控制器的引用。

我在LeftViewController.h

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

didFinishLaunchingWithOptionsAppDelegate.m

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

leftViewController.rightView = rightViewController;

但我得到这个错误AppDelegate.mself.storyboard

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

我怎么解决这个问题?

4

2 回答 2

0

首先 AppDelegate 没有属性storyboard,它是 UIViewController 属性。

其次,如果您想加载主故事板并实例化视图控制器,您应该尝试以下操作:

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

还要确保正确设置视图控制器标识符。

于 2013-06-03T20:14:27.780 回答
0

不要静态地给它们相互引用。相反,当它们是滑动视图控制器的一部分时,self.slidingViewController它将是一个有效的参考,您可以根据实际存在的关系进行导航:

self.slidingViewController.underLeftViewController

使用它时,您应该检查类并转换参考:

LeftViewController *leftController = self.slidingViewController.underLeftViewController;

if ([leftController isKindOfClass:[LeftViewController class]]) {
    leftController. ...;
}
于 2013-06-03T20:16:48.587 回答