我使用Master-Detail Application模板创建了一个项目,但我不需要MasterView。所以我删除了Masterview文件和代码,但这次当我在主屏幕的左侧旋转模拟器/设备时,黑色区域保持不变。我想拉伸我的细节视图来填补所有scren,但我不知道该怎么做。有人可以帮忙吗?提前致谢
注意:我的应用程序needen NavigationController,首先我尝试使用SingleView模板,但我无法在该模板上推送视图,因此我在Master-Detail应用程序模板中创建了我的应用程序。
答案 0 :(得分:1)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
BNT_DetailViewController *detailViewController = [[[BNT_DetailViewController alloc] initWithNibName:@"BNT_DetailViewController" bundle:nil] autorelease];
UINavigationController *detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
self.splitViewController = [[[UISplitViewController alloc] init] autorelease];
self.splitViewController.delegate = detailViewController;
self.splitViewController.viewControllers = [NSArray arrayWithObjects:detailNavigationController, nil];
self.window.rootViewController = self.splitViewController;
[self.window makeKeyAndVisible];
BNT_DetailViewController *detailViewController = [[[BNT_DetailViewController alloc] initWithNibName:@"BNT_DetailViewController" bundle:nil] autorelease];
navigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
这是我的..AppDelegate.m的didFinishLaunchingWithOptions:
的第一次出现,但我用下面改了它:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
//define navigationController in ..AppDelegate.h
BNT_DetailViewController *detailViewController = [[[BNT_DetailViewController alloc] initWithNibName:@"BNT_DetailViewController" bundle:nil] autorelease];
navigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
我回答了我自己的答案,以防对生活同样痛苦的人有所帮助:)