简体   繁体   中英

iPhone - press button open URL?

1) user launch application 2) user press button 3) button loads http://domain.com/mypage/?item=123

How do you trigger http://domain.com/?item=123 , without opening the actual page in the browser?

答案是NSURLConnection

Not 100% sure of what the question is, but you could use a UIWebView . Load that UIWebView in the app with the URL and you should be good to go.

Hope this helps!

NSString* str = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://domain.com/?item=123"] usedEncoding:NULL error:NULL]

I have used a UIWebView set to "hidden". It probably is not the most efficient way but if you normally use UIWebViews and Interface Builder then it is easy. You can also use the webview delegate methods to watch it.

On second thought - use the NSURL String method above but put it in a new thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM