2

是否有关于从 iPhone 应用程序在 Safari 中打开网站的任何可用性指南?

示例:我的应用程序中有一个按钮,点击该按钮时会将用户带到 safari 中的网站 - 这会关闭我的应用程序并打开 safari。

对我来说,在没有警告用户他们即将退出应用程序并打开 safari 的情况下这样做有点糟糕。

是否有任何用户指南说明应如何处理?即你应该提示用户并让他们知道吗?

我一直没能找到官方指南

4

2 回答 2

4
-(void)openSafari
{
   UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"test"
                       message:@"this will open safari, you sure?" 
                       delegate:self cancelButtonTitle:@"no" 
                       otherButtonTitles:@"yes", nil];
              [alert show];
}


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

    if([title isEqualToString:@"yes"]){
    [[UIApplication sharedApplication] openURL:
    [NSURL URLWithString:@"http://www.google.com"]];
  }
}

在你的头文件中。

 @class YourClass : SuperClass<UIAlertViewDelegate>
于 2012-09-07T12:01:17.133 回答
1

如果您在 UIWebView 上加载网络而不是打开 safari(就像 twitter、facebook 和许多其他应用程序一样),那会更好,因为用户不会离开您的应用程序

于 2012-09-07T13:36:59.587 回答