显示我的ArticlesViewController时出现问题。此代码效果很好,但是当“文章”页面出现时,没有状态栏。 我认为导航控制器出了问题,所以我试图添加
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
在AppDelegate的 didFinishLaunchingWithOptions 和ArticlesViewController的 viewDidLoad 和 viewWillAppear 中,但仍然没有结果
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSManagedObjectContext *context = [self managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"Entity"];
localStorage = [[context executeFetchRequest:fetchRequest error:nil] mutableCopy];
NSObject *obj = [localStorage valueForKey:@"isAppLaunchedOnce"];
NSString *condition = [[[obj description] componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] componentsJoinedByString:@""];
NSCharacterSet *unwantedChars = [NSCharacterSet characterSetWithCharactersInString:@"\"()"];
condition = [[condition componentsSeparatedByCharactersInSet:unwantedChars] componentsJoinedByString:@""];
if ([condition isEqual: @"YES"]){
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *rootViewController = (ArticlesViewController*)[storyboard instantiateViewControllerWithIdentifier:@"ArticlesViewController"];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.window.rootViewController = rootViewController;
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1){
navController.navigationBar.tintColor = [UIColor whiteColor];
navController.navigationItem.titleView.tintColor = [UIColor whiteColor];
NSDictionary *titleAttributes = @{
NSFontAttributeName:[UIFont fontWithName:@"Helvetica-Bold" size:14.0],
NSForegroundColorAttributeName:[UIColor whiteColor]
};
navController.navigationBar.titleTextAttributes = titleAttributes;
}
[self.window makeKeyAndVisible];
}
// Override point for customization after application launch.
return YES;
}