Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: create a link button

Tags:

I want to create an IBAction for a button, that when you push it, the app go in background and at the same time open safari at a specific link (example "www.google.it") Can you help me?

like image 827
cyclingIsBetter Avatar asked Jul 19 '11 14:07

cyclingIsBetter


2 Answers

Inside your IBAction method, include the line

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]]; 
like image 160
Patrick Perini Avatar answered Sep 28 '22 02:09

Patrick Perini


If you use interface builder :

Create a UITextView and not a UIButton, write the link as text to textview and select the links checkbox in the interface builder. It will become the link you want at run time.

like image 21
Daniel Avatar answered Sep 28 '22 04:09

Daniel