2016-08-26 5 views
-1

En cliquant sur le bouton d'affichage d'alerte qui est présenté en recevant une notification locale, je dois passer à un contrôleur de vue déjà intégré dans un contrôleur de navigation. S'il vous plaît conseiller comment effectuer cela grâce à l'avanceNaviguer vers un contrôleur de vue depuis la vue d'alerte depuis la notification locale

- (void)application:(UIApplication *)application didReceiveLocalNotification:(nonnull UILocalNotification *)notification 
{ 
    UIApplicationState state = [application applicationState]; 
    if (state == UIApplicationStateActive) 
    { 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Reminder" 
                 message:notification.alertBody 
                 delegate:self cancelButtonTitle:@"Cancel" 
               otherButtonTitles:@"Read more",nil]; 
     _SelectedPOI=[notification.userInfo valueForKey:@"poiID"]; 
     alert.delegate=self; 
     [alert show]; 
    } 
} 


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex == 1) 
    { 
    // here i have to navigate to a view controller which is already embedded 
    in a navigation controller from another view controller 
    } 
} 

Répondre

0

UIAlertView est deprectaed. Vous devez utiliser UIAlertController. Et pour présenter un viewCOntroller ou pour pousser un viewController, vous avez beaucoup d'options.

Une façon est de le faire en utilisant le storyboardID.

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex == 1) 
    { 
    // here i have to navigate to a view controller which is already embedded 
    in a navigation controller from another view controller 

    OtherVC *vc =[self.storyboard instantiateViewControllerWithIdentifier:@"storyboard-id"]; 
    [self presentViewController:vc animated:YES completion:nil]; 
    } 
} 

Assurez-vous que le OtherVC est un UINavigationController dans votre story-board pas le VC intégré dans le contrôleur de navigation.

+0

Merci d'utiliser alertviewcontroller. La notification locale est déclenchée sur la méthode cllocationmanager a mis à jour les emplacements. Donc le contrôleur alertview peut apparaître dans n'importe quel contrôleur de vue quand nous atteignons la distance particulière .. alors je dois naviguer vers le contrôleur de vue de détail qui est déjà intégré dans un contrôleur de navigation en cliquant sur le premier index de alertview @Teja Nandamuri – Mohanraj