我已在app delegate中使用此代码将breathdatetableviewcontroller
设为rootview controller
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
name =[[NSString alloc]init];
birthdate =[[NSString alloc]init];
phone =[[NSString alloc]init];
email =[[NSString alloc]init];
image =[[NSString alloc]init];
birthDateTableViewController =[[BirthDateTableViewController alloc]initWithNibName:@"BirthDateTableViewController" bundle:nil];
navController1 = [[[UINavigationController alloc]initWithRootViewController:birthDateTableViewController]autorelease];
[window addSubview:navController1.view];
[window makeKeyAndVisible];
[FBProfilePictureView class];
[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackOpaque];
self.databaseName = @"birthdateDatabase.sqlite";
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDir = [documentPaths objectAtIndex:0];
self.databasePath = [documentDir stringByAppendingPathComponent:self.databaseName];
[self createAndCheckDatabase];
// sleep(5);
if (sqlite3_open([[self dataFilePath] UTF8String], &database1) != SQLITE_OK)
{
sqlite3_close(database1);
NSLog(@"Failed to open db.");
}
else
NSLog(@"Open DB");
return YES;
}
因此,为了解决此问题,我尝试删除导航栏并添加以下代码,使brithdatetableviewcontroller
成为root view controller
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.birthDateTableViewController = [[BirthDateTableViewController alloc] initWithNibName:@"BirthDateTableViewController" bundle:nil];
self.window.rootViewController = self.birthDateTableViewController;
[self.window makeKeyAndVisible];
但是当我使用它时,它会进入brithdatetableviewcontroller但不能正常工作
所以让我们坚持我以前做过的事情,我怎么能做出类似的事情,当它在rootview中时应该显示,但是当它进入另一个viewcontroller并且那些viewcontroller有自己的nevigationbar和按钮时它应该被隐藏。
我试图将它隐藏在另一个viewcontroller中,但那不能在这里工作。
请建议我该怎么做才能克服这个问题?
答案 0 :(得分:0)
在viewController中
- (void)viewWillAppear:(BOOL)animated
{
// If you wnat Navigation Bar then
[self.navigationController setNavigationBarHidden:NO];
// Else if you don't want
[self.navigationController setNavigationBarHidden:YES];
}
答案 1 :(得分:0)
在 AppDelegate.h 类中,创建一个导航控制器:
@property(非原子,强)UINavigationController * navController;
在 APPDELEGATE.M 中,将本地Navigation Contooler对象指定给该属性。
(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:< MYViewController >];
self.navController = nav;
[self.window addSubview:nav.view];
}