Hyperlinks within "about" text for iphone application
Yep, use a UIWebView and put static HTML in it.
Like so:
[myWebView loadHTMLString:@"<html><head></head><body style=\"font-family: sans-serif;\"> .... </body></html>" baseURL:nil];
To launch the web browser at the specified url:
NSURL *target = [[NSURL alloc] initWithString:@"http://www.stackoverflow.com"];
[[UIApplication sharedApplication] openURL:target];
This code can be run anywhere. I sub-classed UILabel, added the touchedsEnded method and place it in there. (Don't forget to set labelname.userInteractionEnabled = YES;)
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSURL *target = [[NSURL alloc] initWithString:@"http://www.stackoverflow.com"];
[[UIApplication sharedApplication] openURL:target];
}
You can trigger safari by calling UIApplication openURL: method with the URL you wish to display. This will close your app, and then open safari ( or mail / youtube / etc ).
You will want to make your link somehow, perhaps in a button. That part is up to you.
If you want to embed html content into your view, then by all means use a UIWebView.
Documentation:
- UIApplication openURL: (deprecated)
- UIApplication openURL:options:completionHandler: (iOS 10+)
- iPhone URL Scheme Reference