Код: Выделить всё
// The binding logic of the button
(void)jumpToSecondViewController {
NSLog(@"content of the navigation stack (before):%@",self.navigationController.viewControllers);
SecondViewController *secondVC = [[SecondViewController alloc] init];
secondVC.receivedMessage = @"Hello World";
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert" message:@"This is an alert." preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* defaultAction1 = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction action) {
//[self.navigationController pushViewController:secondVC animated:YES];
NSLog(@"ok");
}];
UIAlertAction defaultAction2 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"no");
}];
[alert addAction:defaultAction1];
[alert addAction:defaultAction2];
[self presentViewController:alert animated:NO completion:nil];
[self.navigationController pushViewController:secondVC animated:NO];
NSLog(@"content of the navigation stack (after):%@", self.navigationController.viewControllers);
NSLog(@"here");
}
Код: Выделить всё
// The binding logic of the button
(void)jumpToSecondViewController {
NSLog(@"content of the navigation stack (before):%@", self.navigationController.viewControllers);
SecondViewController *secondVC = [[SecondViewController alloc] init];
secondVC.receivedMessage = @"Hello World";
[self.navigationController pushViewController:secondVC animated:NO];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert" message:@"This is an alert." preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* defaultAction1 = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction action) {
//[self.navigationController pushViewController:secondVC animated:YES];
NSLog(@"ok");
}];
UIAlertAction defaultAction2 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"no");
}];
[alert addAction:defaultAction1];
[alert addAction:defaultAction2];
[self presentViewController:alert animated:NO completion:nil];
//[self.navigationController pushViewController:secondVC animated:NO];
NSLog(@"content of the navigation stack (after):%@",self.navigationController.viewControllers);
NSLog(@"here");
}
< /code>
После нажатия сначала представленное предупреждение появится нормально. < /p>
// The binding logic of the button
(void)jumpToSecondViewController {
NSLog(@"content of the navigation stack (before):%@",self.navigationController.viewControllers);
/// ......
NSLog(@"content of the navigation stack (after):%@",self.navigationController.viewControllers);
NSLog(@"here");
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... mmediately
Мобильная версия