在SplitViewController之前插入View控制器

时间:2012-06-01 11:36:23

标签: objective-c ios5 uisplitviewcontroller viewcontroller uiapplicationdelegate

我想在我的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

0 个答案:

没有答案