[英]How to bring App in Foreground programmatically
I develop some LocalNotifications for my iOS8-App using UIMutableUserNotificationAction
我使用UIMutableUserNotificationAction
为我的iOS8-App开发了一些UIMutableUserNotificationAction
In case of the App is running in background and the user touches at this UIMutableUserNotificationAction
the app should be comeback to foreground. 如果应用程序在后台运行,并且用户触摸此UIMutableUserNotificationAction
该应用程序应回到前台。
How can i solve that ? 我该如何解决?
The event that UIMutableUserNotificationAction
fires is: UIMutableUserNotificationAction
触发的事件是:
-(void)application:(UIApplication *)application handleActionWithIdentifier:(NSString
*)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler
You should instantiate your storyboard and view controllers in application:handleWithIdentifier.. and push the view controller to the navigation controller if you have one or set as the root view controller if you don't have one. 您应该在application:handleWithIdentifier ..中实例化情节提要和视图控制器,如果有一个,则将视图控制器推到导航控制器,否则将其设置为根视图控制器。
You can also use application:didReceiveLocalNotification:
method. 您也可以使用application:didReceiveLocalNotification:
方法。
Something like this: 像这样:
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
MyViewController *presenterVC = [_storyBoard instantiateViewControllerWithIdentifier:@"MyViewController"];
[_navigationController pushViewController:presenterVC animated:NO];
self.window.rootViewController = _navigationController;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.