Linking of UITable Objects to URLS in xcode
In xcode, how开发者_C百科 do I link an object to a URL so that when a user taps the object, it automatically links him to the URL. I already have a table view with some objects on it
Assuming you want to display the content within your application, a UIWebView is what you want to use.
The UIWebView Class Reference has links to several samples.
--- edit ---
To open a URL in Safari, use the -openURL
method on UIApplication
. For example:
// launch Safari app (we exit)
if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://stackoverflow.com"]]) {
UIAlertView *openURLAlert = [[UIAlertView alloc] initWithTitle:@"Error launching Safari"
message:@"Sorry, unable to launch Safari application"
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[openURLAlert show];
[openURLAlert release];
}
精彩评论