搜索
您的当前位置:首页正文

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

来源:知库网

代码如下:

- (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 
}
Top