How do I create a button to go to a web page

Hi all,

I am new to developing an Iphone application and have a question?

I want to create an image button and when the user touches the button it takes them to a web page to display our current sales.  

What is the best way to do this?
tradomskiAsked:
Who is Participating?
 
SpeedyApocalypseConnect With a Mentor Commented:
Hello Tom,

You have a couple options here.  One of them is to have an in-house Web View to view the website or to transfer to Safari to bring up the website.

Web View

You can create a UIWebView instance through Interface Builder or by add the sub-view.  

Here is a tutorial (or two) to create the UIWebView in your application:

- http://www.iphonesdkarticles.com/2008/08/uiwebview-tutorial.html
- http://dblog.com.au/iphone-development/iphone-sdk-tutorial-build-your-very-own-web-browser/

Safari

You can simply switch to Safari instead of hosting the web-view yourself.  However, this will lead users away from your application and could be un-wanted.

Here is an example of loading Google through Safari.  Due note, this will only work on device as the Simulator does not have Safari.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com/"]];

Open in new window


If you have any other questions, please do not hesitate to ask.
0
 
tradomskiAuthor Commented:
Thank you for your help.

Tom
0
 
nish_trCommented:
Hi,
     The best is use WebView along with delegate -
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
}

Add and activity indicator to your webview and hide it in the above delegate. It shows that process is going on. This delegate called when webview finshed loading the content of that URL

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.