gpt4 book ai didi

ios - 以编程方式删除 PageViewController

转载 作者:行者123 更新时间:2023-11-29 00:26:40 26 4
gpt4 key购买 nike

我已按如下方式以编程方式添加了 pageviewController。有用。但是,当我尝试使用 [self.pageViewController.view removeFromSuperview]; 删除时,它并没有删除它。

添加 pageViewController

self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageViewController"];
self.pageViewController.dataSource = self;
self.pageViewController.delegate = self;
PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];

移除 pageViewController

[self.pageViewController.view removeFromSuperview];

最佳答案

使用下面的一组说明删除您的 pageViewController:

[self.pageViewController willMoveToParentViewController:nil];
[self.pageViewController.view removeFromSuperview];
[self.pageViewController removeFromParentViewController];

关于ios - 以编程方式删除 PageViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42827280/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com