Reputation: 798
I am loading a webview with some url using:
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://abc-ecatalogue.xyz-ar.com/"]]];
then i am checking if the home page is being loaded then i dont want the navigation bar for this i am using:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
// Here you can check the URL
NSURL *url = [request URL];
NSString*str=@"http://abc-ecatalogue.xyz-ar.com";
if ([url.absoluteString isEqualToString:@"http://havells-ecatalogue.adstuck-ar.com/"])
{
self.navigationController.navigationBarHidden = YES;
NSLog(@"hello");
return NO;
}
else
{
self.navigationController.navigationBarHidden = NO;
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style: UIBarButtonItemStyleBordered target:self action:@selector(Back)];
self.navigationItem.leftBarButtonItem = backButton;
}
return YES;
}
but when the control goes inside the loop the web view is not loaded and the log which i have printed is continously printed.
Upvotes: 1
Views: 145
Reputation: 2456
You have self.navigationController.navigationBarHidden = NO;
in both the if
& else
part. You should change it to YES
in the if section.
EDIT:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
// Here you can check the URL
NSURL *url = [request URL];
NSString*str=@"http://abc-ecatalogue.xyz-ar.com";
if ([url.absoluteString isEqualToString:@"http://havells-ecatalogue.adstuck-ar.com/"]) {
self.navigationController.navigationBarHidden = YES;
NSLog(@"hello");
} else {
self.navigationController.navigationBarHidden = NO;
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style: UIBarButtonItemStyleBordered target:self action:@selector(Back)];
self.navigationItem.leftBarButtonItem = backButton;
}
return YES;
}
Upvotes: 1