iOS: Is it possible to open NSURLRequest directly in Safari?

后端 未结 2 1468
甜味超标
甜味超标 2020-12-18 06:21

I\'m not talking about a UIWebView, I want to open the mobile safari app using an NSURLRequest.

Why? In my app, the user has already logged

2条回答
  •  无人及你
    2020-12-18 07:06

    It would be simpler to use an NSURL, or just an NSString, or just a char* for that matter. I'm not sure if that works on the iPhone, it should, since the iPhone runs parallel with Darwin just like OSX, but there are some restrictions to that on the iPhone. This definitely works on a mac though.

    NSString *url = @"http://www.apple.com";
    NSURL *myURL = [NSURL URLWithString:url];
    system([ [NSString 
              stringWithFormat:@"Open -a Safari %@", 
              [NSString stringWithContentsOfURL:myURL encoding:NSUTF8StringEncoding error:NULL] ]
              cStringUsingEncoding:NSUTF8StringEncoding]);
    

    Also, I might suggest that that's a bad idea (if it might be avoided). As an iPhone user, I'm sure I'm not alone in finding it very irritating when developers take me away from the app I'm currently in.

提交回复
热议问题