I'm embedding this web site into my app like this:
NSString *url = [NSString stringWithFormat:@"https://mobile.twitter.com/search?q=%@", @"@test OR #test"];
url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[self.twitterWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
self.twitterWebView.scalesPageToFit = YES;
And I have 2 buttons for going back and forward in this web site. I'm calling
[self.twitterWebView goBack];
and
[self.twitterWebView goForward];
accordingly.
This works fine on iOS 6 but on iOS 7, my web view's canGoBack and canGoForward properties are NO and thus my back and forward buttons do not work.
As a side note, when the app is installed the first time, and the page is loaded the first time, my buttons work. But when I run my app again, and when I tap on a link on the web site, my web view's canGoBack property begins returning always NO.
How can I solve this?
EDIT: I uploaded a mini test app that demonstrates my problem. You can download it from here. Please run the app on an iOS 7 simulator, see that the back button is working on the first installation of the app. Then quit, run the app again and you'll see that it'll stop working.
By the way the problem seems to be about the twitter mobile site. You can try another web site address and see that.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…