2014-10-10 24 views

回答

0

是的,您可以使用iOS8的新方法handleActionWithIdentifier來執行此任務。每當你按動作按鈕,這些代表就會打電話。

  1. 委託localNotification:當你的應用程序已經被用戶選擇從本地通知的動作被激活時調用。

    - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler 
    
  2. 委託remoteNotification:當你的應用程序已經被用戶選擇從遠程通知的動作被激活時調用。

    - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler 
    

注意:應儘快你處理完動作調用完成處理程序。

然後你可以得到你的rootViewController使用這個,然後重定向到其他ViewController。

- (UIViewController*)GetTopViewController 
{ 
    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate]; 
    UIViewController *rootViewController = appDelegate.window.rootViewController; 
    if ([rootViewController isKindOfClass:[UINavigationController class]]) 
    { 
     UINavigationController* rvc = (UINavigationController*)rootViewController; 
     rootViewController = rvc.visibleViewController; 
    } 
    return rootViewController; 
} 

其他相關Question Link

+0

感謝。我已經有了這些代表。如何在特定的視圖控制器上打開應用程序頂部? – user3626407 2014-10-13 08:06:44

+0

再次檢查答案... – Rajneesh071 2014-10-13 10:07:14

相關問題