下图说明了我要做的事情:
http://img337.imageshack.us/img337/1475/multinav.png
这适用于iPad应用。可能吗?如果是这样,有人可以发布骨架代码吗?
提前致谢
答案 0 :(得分:1)
是的,这是可能的。骨架代码:
标题文件:
@interface SGBSplitViewController : UIViewController
@property (nonatomic, strong, readonly) UIViewController *leftViewController;
@property (nonatomic, strong, readonly) UIViewController *rightViewController;
- (id)initWithLeftViewController:(UIViewController *)leftViewController
rightViewController:(UIViewController *)rightViewController;
@end
实施档案:
@implementation SGBSplitViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
return nil;
}
- (id)initWithLeftViewController:(UIViewController *)leftViewController
rightViewController:(UIViewController *)rightViewController
{
self = [super initWithNibName:nil bundle:nil];
if (self)
{
_leftViewController = leftViewController;
_rightViewController = rightViewController;
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self addChildViewController:self.leftViewController];
[self.view addSubview:self.leftViewController.view];
[self.leftViewController didMoveToParentViewController:self];
[self addChildViewController:self.rightViewController];
[self.view addSubview:self.rightViewController.view];
[self.rightViewController didMoveToParentViewController:self];
}
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
self.leftViewController.view.frame = <frame>;
self.rightViewController.view.frame = <frame>;
}