关闭视图时分页视图层次结构被破坏
Paging view hierarchy broken when dismissing a view
我将 SLPagingView (https://github.com/StefanLage/SLPagingView/) 开源库用于基于分页视图的应用程序,例如 Twitter 或 Tinder。
从某个页面我打开一个详细视图。当我回来时,分页视图的布局被破坏了。
DetailViewController.m
- (void)backButtonPressed {
[self dismissViewControllerAnimated:YES completion:nil];
}
事实上,我注意到应用的层次结构就在 DetailView 出现之前被破坏了。
SomePageViewController.m
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Perform segue to detailView
[self performSegueWithIdentifier:@"actionDetail" sender:nil];
/* Does not work with a modal view controller either
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main"bundle:nil];
DetailViewController *detailViewController =
(DetailViewController *)
[storyboard instantiateViewControllerWithIdentifier:@"detailcontroller_id"];
[self pushViewController:detailViewController animated:YES];*/
}
我收到了 Presenting view controllers on detached view controllers is discouraged
警告。我尝试用 self.navigationController
或 self.parentViewController.navigationController
替换 self
但两者都不起作用。
是否有人使用此库解决了这个问题或知道解决方案?
已修复。
我修改了 SLPagingView 库。在initWithNavBarControllers:
、initWithNavBarItem:
等生命周期方法中添加[self addChildViewController:ctr]
。
检查差异:https://www.diffchecker.com/cnlvslym
我将 SLPagingView (https://github.com/StefanLage/SLPagingView/) 开源库用于基于分页视图的应用程序,例如 Twitter 或 Tinder。 从某个页面我打开一个详细视图。当我回来时,分页视图的布局被破坏了。
DetailViewController.m
- (void)backButtonPressed {
[self dismissViewControllerAnimated:YES completion:nil];
}
事实上,我注意到应用的层次结构就在 DetailView 出现之前被破坏了。
SomePageViewController.m
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Perform segue to detailView
[self performSegueWithIdentifier:@"actionDetail" sender:nil];
/* Does not work with a modal view controller either
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main"bundle:nil];
DetailViewController *detailViewController =
(DetailViewController *)
[storyboard instantiateViewControllerWithIdentifier:@"detailcontroller_id"];
[self pushViewController:detailViewController animated:YES];*/
}
我收到了 Presenting view controllers on detached view controllers is discouraged
警告。我尝试用 self.navigationController
或 self.parentViewController.navigationController
替换 self
但两者都不起作用。
是否有人使用此库解决了这个问题或知道解决方案?
已修复。
我修改了 SLPagingView 库。在initWithNavBarControllers:
、initWithNavBarItem:
等生命周期方法中添加[self addChildViewController:ctr]
。
检查差异:https://www.diffchecker.com/cnlvslym