ios - Objective-C iPhone - Open URL in Safari immediately and exit app -


i able open url in safari using:

[[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"www.myurl.com"]]; 

it works fine, takes more 10 seconds in simulator. i've tried putting code inside app delegate's didfinishlauchingwithoptions method or view controller's viewdidload method, still takes on 10 seconds load. black screen nothing on entire duration before opens safari. there way decrease load time? simulator bug?? still trying devices registered test on actual devices.

the funny thing when add uibutton's action method, app loads right away, user must tap uibutton launch url in safari.

my objective here have app upon startup, launches hard-coded url in safari. app should exit able again when user taps on app icon. suggestions?

here's snippet of attempted before in viewcontroller.m has 10 second black screen if want try yourself:

- (void)viewdidload {     [super viewdidload];     [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"www.myurl.com"]];     exit(0); } 

why don't use add home screen @ mobile safari?

enter image description here

however if want call safari @ beginning of launching app, try this:

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     // override point customization after application launch.       dispatch_after(dispatch_time(dispatch_time_now, (int64_t)(1.0 * nsec_per_sec)), dispatch_get_main_queue(), ^{         [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"http://www.google.com"]];         exit(0);     });      return yes; } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -