0

Я новичок в разработке iOS. У меня есть панель с навигационным контроллером и UIViewController.navigationController pushViewController от UIPageViewController не работает

В UIViewController пользовательском классе я добавляю три UIViewController под UIPageViewController:

_one= [self.storyboard instantiateViewControllerWithIdentifier:@"View1"]; 
_two = [self.storyboard instantiateViewControllerWithIdentifier:@"View2"]; 
_three = [self.storyboard instantiateViewControllerWithIdentifier:@"View3"]; 
_page = [[CustomUIPageViewController alloc] initWithParentViewController:self]; 
_page.viewControllers = @[_one, _two, _three]; 
[self.view addSubview:_page.view]; 
... 

Я хочу, чтобы показать вид со страницы _TWO вызовом этот код:

ResultViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"ResultBoard"]; 
     [self.navigationController pushViewController:view animated:YES]; 

Но это не работает, я также попробуйте:

[self.parentViewController.navigationController pushViewController:view animated:YES]; 
+0

какой вид показывает? –

+0

@ S.Jain Это страница раскадровки с UIViewController. – DzungPV

ответ

0

Я могу решить свою проблему теперь. Это не «чистый» способ, но он работает. На _TWO контроллер добавить:

@property (weak, nonatomic) UINavigationController *navigationCustomController; 

А потом, когда я инициализации добавить:

_two.navigationCustomController = self.navigationController; 

После этого я просто позвонить:

ResultViewController *view = [self.storyboard instantiateViewControllerWithIdentifier:@"ResultBoard"]; 
[_navigationCustomController pushViewController:view animated:YES]; 

И это работает.

Смежные вопросы