1

Me again. Right, in my tab bar application one of my tabs loads a webview and works perfectly. However I want the tab to return to this view when pressed again.

For example, the tab brings up a car sales part of my companies website, should somebody click on the home part of this UIWebView the webview will go there, fair enough I expect this. But when I close the app and reopen or simply navigate away from tab and back again, I want the original page I wanted loaded in the first place. So when the user returns to the app or tab, it resets back to the car sale page and not the last page they left it on.

Any ideas?

4

1 回答 1

0

viewWillAppear()在视图控制器的orviewDidAppear()函数中刷新您的 url 。

如果没有覆盖,请在您的 secondviewcontroller.m 文件中添加其中一个,如下所示:

类似的东西:

- (void)viewWillAppear:(BOOL)animated { 

    NSString *urlAddress = @"http://www.google.com";
    //Create a URL object.
    NSURL *url = [NSURL URLWithString:urlAddress];

    //URL Requst Object
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    //Load the request in the UIWebView.
    [webView loadRequest:requestObj];    

    [super viewWillAppear:animated];  
} 

就在我的脑海中:)

于 2012-07-23T12:18:41.573 回答