Ios 从本地通知的警报视图导航到视图控制器
单击通过接收本地通知显示的警报视图按钮时,我必须移动到已嵌入导航控制器中的视图控制器。请提前告知如何履行此感谢Ios 从本地通知的警报视图导航到视图控制器,ios,objective-c,uialertview,uilocalnotification,Ios,Objective C,Uialertview,Uilocalnotification,单击通过接收本地通知显示的警报视图按钮时,我必须移动到已嵌入导航控制器中的视图控制器。请提前告知如何履行此感谢 - (void)application:(UIApplication *)application didReceiveLocalNotification:(nonnull UILocalNotification *)notification { UIApplicationState state = [application applicationState]; if (
- (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
}
}
UIAlertView
不受欢迎。您应该使用UIAlertController
。要显示viewCOntroller或推送viewCOntroller,您有许多选项
一种方法是通过使用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];
}
}
确保另一个VC是故事板中的
UINavigationController
,而不是嵌入导航控制器中的VC。谢谢我使用alertviewcontroller。在cllocationmanager更新位置方法时激发本地通知。因此,当我们到达特定距离时,alertview控制器可能会出现在任何视图控制器中。。然后我必须通过单击alertview@Teja Nandamuri的第一个索引导航到已经嵌入导航控制器中的细节视图控制器