Ok, so the following code gets the title of a page loaded in a UIWebView and then checks to see if the title contains the word "table". If it does then it unhides the toolbar. If it doesn't then it hides the tool bar. This works fine at first when a page without "table" in the title loads and when you browse to one that does have "table" in the title it shows the toolbar. The problem occurs when you go back to a page without "table" in the title, the new title appears in the NSLog, but the toolbar doesn't disappear.
NSString * webtitle = [viewWeb stringByEvaluatingJavaScriptFromString:@"document.title"];
NSLog(@"Title is: %@", webtitle);
if ([webtitle rangeOfString:@"Table"].location == NSNotFound) {
[toolbar setHidden:YES];
} else {
[toolbar setHidden:NO];
}
Any help is appreciated.
Thanks!
EDIT: I should have said that I am executing this within
- (void)webViewDidFinishLoad:(UIWebView *)wv
{
}
EDIT 2: I have now added in NSLogs to fire when the if runs:
if ([webtitle rangeOfString:@"Table"].location == NSNotFound) {
NSLog(@"Hidden");
[toolbar setHidden:YES];
} else {
NSLog(@"Not Hidden");
[toolbar setHidden:NO];
}
"Hidden" is returned when you browse to a page without "table" but the toolbar is still displayed so it looks as thought [toolbar setHidden:YES]; isn't working for some reason. Does anybody have any clues?