Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-12-2010, 10:35 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 13
Default How do you open Safari with a button

Okay...
I am not having any technical trouble so there is no code to post, but I have not been able to find documentation on a given task I want to perform

I want the user to press a button in my iphone app which will in turn close my app and open safari and direct it too a specified URL.

How would I go about doing this? Any direction would be good,

Also does the iphone GUI support .png alpha transparency?

Thanks

P.J.
lmpeejay is offline   Reply With Quote
Old 03-12-2010, 10:38 PM   #2 (permalink)
iPhone SDK learner
 
Join Date: Feb 2010
Location: Illinois, USA
Posts: 417
Default

Quote:
Originally Posted by lmpeejay View Post
Okay...
I want the user to press a button in my iphone app which will in turn close my app and open safari and direct it too a specified URL.
you do it with this code:
Code:
-(IBAction)yourAction {
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://yourWebsiteHere.com"]];
}
Batman is offline   Reply With Quote
Old 03-12-2010, 10:43 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 13
Default

Thank you so much...

Quote:
Originally Posted by Batman View Post
you do it with this code:
Code:
-(IBAction)yourAction {
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://yourWebsiteHere.com"]];
}
lmpeejay is offline   Reply With Quote
Old 03-13-2010, 06:47 PM   #4 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 4
Default

Sorry to hijack this thread...but I want to do something similar like yours, except I want my app to go to a specific address, such as myfile.php?id=1&valid=none and I want to do it without opening the browser. Does anyone know how to do this?

Again, sorry to hijack but my other thread wasn't getting any responses...I've been trying to figure this out for the last 3 days straight without any success. Any help would be appreciated!
ardvarkm87 is offline   Reply With Quote
Old 03-13-2010, 07:07 PM   #5 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 4,814
Default

Quote:
Originally Posted by ardvarkm87 View Post
Sorry to hijack this thread...but I want to do something similar like yours, except I want my app to go to a specific address, such as myfile.php?id=1&valid=none and I want to do it without opening the browser. Does anyone know how to do this?

Again, sorry to hijack but my other thread wasn't getting any responses...I've been trying to figure this out for the last 3 days straight without any success. Any help would be appreciated!

What does it mean to go to a specific address without opening the browser? Does that link return a file? Does it return HTML content that you want to display in your application?

If you want to go to a web page but display it inside your app, you need to create a UIWebView.

If you want to fetch data from a remote file that you will use in your program, you will need to write some code to submit an HTTP get. Look at the NSURLConnection class. You would need to create an NSURLConnection and set up a delegate to handle the incoming data from the URL request.


Regards,

Duncan C
WareTo
Duncan C is offline   Reply With Quote
Old 03-13-2010, 07:31 PM   #6 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 18
Default

Quote:
Originally Posted by ardvarkm87 View Post
Sorry to hijack this thread...but I want to do something similar like yours, except I want my app to go to a specific address, such as myfile.php?id=1&valid=none and I want to do it without opening the browser. Does anyone know how to do this?

Again, sorry to hijack but my other thread wasn't getting any responses...I've been trying to figure this out for the last 3 days straight without any success. Any help would be appreciated!

Ardvarkm87,

You can have a UIWebView open your URL that has query string variables and that could be launched from a button, but that button would have to call a modal view controller or push a view controller onto the stack and pass in that URL in order for the webview to display, unless your webview is already in the view and you have some type of button in that view that changes the target of the webview.


Back to the original question, if you are going to close your app and open the Safari browser, I would recommend using an AlertView to let the user decide if they want to close the app and proceed or cancel and return to your app. Apple is pretty clear about making sure the user knows that is going on with the app at all times and that any action that could drastically change the app, such as closing it, first presents the user with the option to say no.
iphonedave is offline   Reply With Quote
Old 10-21-2011, 05:07 AM   #7 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 1
Default Accessing a URL from pressing a button

Quote:
Originally Posted by Batman View Post
you do it with this code:
Code:
-(IBAction)yourAction {
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://yourWebsiteHere.com"]];
}
Hello,

I am having the same problem. Cannot get my button to access my website.
The code that you have specified us to try, which header does that go into is it ViewController.h or ViewController.m

regards

Matt
Mattw0909 is offline   Reply With Quote
Old 11-01-2011, 04:38 PM   #8 (permalink)
Registered Member
 
Join Date: Nov 2011
Posts: 1
Question Issues with this code:

I have written the same exact thing, and Im completely new to all this, going from being a iPhone UI designer, to learning the xCode side of everything. But My link won't open Safari, and close my app. I have no errors showing up, and everything is looking like the other forums and videos ive seen. The simulator shows that there is a button, and shows the tapped state, but nothing happens.

Suggestions? Thoughts?

The ONLY thing I dont know, and if this is a issue, please let me know, is that I am teaching myself by continuing to work off of the Hello World. app thats the "start" app for learning. Im just building off of it, and started with a "Window-based application", the one video I saw that showed me the code first, used a "view based application". What is the difference?

Thanks!!
devanescence is offline   Reply With Quote
Reply

Bookmarks

Tags
ibaction, pngs, safari, uibutton

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 332
21 members and 311 guests
@sandris, ADY, BrianSlick, dacapo, Dani77, dre, HDshot, HemiMG, JasonR, MarkC, mer10, nibeck, prchn4christ, ryandb2, spiderguy84, themathminister, timle8n1, tomtom100, vogueestylee, vvenkatachallam
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,883
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, vvenkatachallam
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:09 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0