iOS - 在转到后台之前打开浏览器

时间:2011-11-30 11:54:45

标签: objective-c ios uiapplicationdelegate

我正在编写以下代码,以便在应用程序进入后台时打开浏览器:

- (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”中打开浏览器吗?

1 个答案:

答案 0 :(得分:0)

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

PS:

为什么你会想要这样做 - 当然这真的会让用户感到烦恼?