アプリからsafariを起動して指定したURLを開く[Objective-C][iOS][iPhone]
めっちゃ簡単でちょっと感動したのでメモ。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://shiro-goma.hatenablog.com/entry/2014/06/01/041811"]];
これを起動したいタイミングで挟んであげればそれだけでsafariが立ち上がってくれます。
例えば、tableView内のCellがタップされた時にsafariを起動したいときは
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://shiro-goma.hatenablog.com/entry/2014/06/01/041811"]];
こんな感じで。簡単!