Reputation: 2107
I need to make the navigation bar HIDDEN in a view controller. I do
- (void)viewDidLoad
{
[self.navigationController.navigationBar setHidden:YES];
[super viewDidLoad];
}
But when I need to start a new thread to load webview when the app is launched,
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
[NSThread detachNewThreadSelector: @selector(doStuff) toTarget:self withObject:NULL];
return self;
}
- (void)doStuff
{
NSLog(@"Starting a new thread ...");
url = [NSURL URLWithString:@"http://www.google.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[newsWebView loadRequest:request];
}
the navigation bar still appears.
I just want to make the navigationbar hidden and load the webview in separate thread in this view controller when the app is launched. When I tap the tabBar, this viewController will be ready for user to view.
May I know what is the problem? or I'm doing it in the wrong way? Thank you...
Upvotes: 0
Views: 189
Reputation: 5267
You have to hide the navigationBar in the parent or it's previous view when you try to navigate to this view and the problem is solved like this
Assume that this view is navigated when some button is clicked in previous view
in button's action method put this line before navigate to the current view
[self.navigationController.navigationBar setHidden:YES];
Happy Coding :)
Upvotes: 1
Reputation: 1
hi i think it is better to place this line of code
[self.navigationController.navigationBar setHidden:YES];
in method
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
I hope it will work it out.
Upvotes: 0