1

我想在我的 SplitViewController 之前插入一个 RootViewController。我在 AppDelegate 中的代码是:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [_window addSubview:[_viewController view]];
    [_window makeKeyAndVisible];

    return YES;
}

将调用委托给我的 rootviewcontroller,在此我想调用我的 splitviewcontroller:

- (void)viewDidLoad
{
    [super viewDidLoad];

    SplitViewController *splitViewController = [SplitViewController initApp];
    [[self navigationController] pushViewController:splitViewController animated:YES];

}

在我的 SplitViewController 我有这个方法:

+ (YetSplitViewController*) initApp
{
    YetSplitViewController * cont = [[YetSplitViewController alloc] initWithNibName:@"YetSplitViewController" bundle:nil];
    if (NO) 
    { 
        cont.splitWidth = 15.0;
    }
    return [cont autorelease];
}

之后没找到好的.......

我从委托到我的 SplitViewController 的第一个代码调用:

@interface TemplateAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong,   nonatomic)    IBOutlet UIWindow               *window;
@property (readonly, nonatomic)    IBOutlet YetSplitViewController *splitViewController;

@property (readonly, nonatomic)    IBOutlet MasterViewController   *rootViewController;
@property (readonly, nonatomic)    IBOutlet DetailViewController   *detailViewController;

@end

@implementation TemplateAppDelegate

@synthesize window                   = _window;
@synthesize splitViewController      = _splitViewController;
@synthesize rootViewController       = _rootViewController;
@synthesize detailViewController     = _detailViewController;


- (void)dealloc
{
    [_window release];
    [_splitViewController release];

    [_rootViewController release];
    [_detailViewController release];

    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    if (NO) 
    { 
    _splitViewController.splitWidth = 15.0;
    }

    [_window addSubview:_splitViewController.view];
    [_window makeKeyAndVisible];

    return YES;
}

@end
4

0 回答 0