tags:

views:

63

answers:

1

i have a button called "Visit Website" If Visit Website is clicked then the website supplied will be opened in the browser. My requirement is, when closing the browser the user will be brought back to the same screen i want to do it in this way please guide me how i can do that

+1  A: 

You can open webpages within your iPhone application using UIWebViewController. Push a new ViewController to your navigation stack and in its loadView method create a UIWebViewController.

[self pushViewController:[[[MyViewController alloc] initWithURL:navigationURL] autorelease] animated:animated];

and in MyViewController loadView:

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0F, 0.0F, 320.0F, 480.0F)];
webView.delegate = self;

[webView loadRequest:[NSURLRequest requestWithURL:navigationURL]]];

or for local HTML file you would replace the last line with something like this.

[webView loadHTMLString:[htmlCode htmlEncodedString] baseURL:nil];

Now whatever your user does in this webview, he/she can always tap the back button in the navigation bar to return.

texmex5