美文网首页
iOS | App跳转Safari直接打开指定的网页

iOS | App跳转Safari直接打开指定的网页

作者: Rickie_Lambert | 来源:发表于2018-09-20 11:31 被阅读128次

代码如下:

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIButton *btnSkip = [UIButton buttonWithType:UIButtonTypeCustom];
    btnSkip.frame = CGRectMake((self.view.frame.size.width - 280)/2, 30, 280, 50);
    btnSkip.backgroundColor = [UIColor redColor];
    [btnSkip setTitle:@"测试跳转到Safari" forState:UIControlStateNormal];
    [btnSkip setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btnSkip addTarget:self action:@selector(skipToSafari) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btnSkip];
    
    
}

- (void)skipToSafari
{
    // app跳转打开safari 跳转打开指定设置的网页
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http:www.baidu.com"]];
}

相关文章

网友评论

      本文标题:iOS | App跳转Safari直接打开指定的网页

      本文链接:https://www.haomeiwen.com/subject/dxignftx.html