2011-11-30 90 views
0

我写下面的代码打开浏览器时,应用程序将去后台打开浏览器:iOS版 - 睡前背景

- (void)applicationWillResignActive:(UIApplication *)application 
{ 
    /* 
    Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
    Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 
    */ 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]]; 
} 

,但其不开放。有什么建议么?

我可以在“applicationWillResignActive”中打开浏览器吗?

回答

0

你的代码看起来不错,所以我猜iOS不会让你这样做。您的应用已被告知进入后台 - 您无法打开新的应用!

PS:

为什么你想这样做 - 这肯定会只是真的惹恼用户?

+0

我同意你的意见。我刚刚得到了这个要求...... – Satyam

+1

然后,作为开发人员的工作是推回给你的老板/客户,这是一个不好的要求(尽管说起来容易做起来难)。我只是告诉他们,苹果公司不会让你这样做:) – deanWombourne

+0

..或更好的是,操作系统不会让你。 – TigerCoding