我的应用程序有一个屏幕教程。我有一个UIPageViewController
设置来管理3个视图控制器。一旦你到达教程的最后一个视图,你按下“完成”按钮,教程应该消失。
我似乎找不到弹出/关闭教程的方法。我尝试过以下方法:
[self dismissViewControllerAnimated:YES completion:nil];
[self.navigationController popViewControllerAnimated:YES];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
任何想法都会受到赞赏。
正在管理的视图控制器是UIViewController
的子视图,如果有任何帮助的话。
EDIT 这是我设置视图的方式: 在我的UIPageViewController中,我有以下内容:
-(void)viewDidLoad{
[self.pageController setViewControllers:@[tutorialPages[0]]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
[self addChildViewController:self.pageController];
[[self view] addSubview:[self.pageController view]];
[self.pageController didMoveToParentViewController:self];
}
- (void)setupContentViews{
ScreenTutorial_1ViewController *screenTutorial1 = [[ScreenTutorial_1ViewController alloc] initWithNibName:@"ScreenTutorial_1ViewController" bundle:nil];
ScreenTutorial_2ViewController *screenTutorial2 = [[ScreenTutorial_2ViewController alloc] initWithNibName:@"ScreenTutorial_2ViewController" bundle:nil];
ScreenTutorial_3ViewController *screenTutorial3 = [[ScreenTutorial_3ViewController alloc] initWithNibName:@"ScreenTutorial_3ViewController" bundle:nil];
tutorialPages = @[screenTutorial1, screenTutorial2, screenTutorial3];
NSLog(@"tutorPages = %@", tutorialPages);
}
答案 0 :(得分:1)
首先,我强烈建议您使用:
[[NSUserDefaults standardUserDefaults] setObject:@YES forKey:@"hasSeenTutorial"];
其次,您如何展示您的PageViewController?为了像你一样解雇它,你需要使用(来自UIViewController):
[self presentViewController:tutorial animated:YES completion:nil];
其中 tutorial 是您的Tutorial View控制器。这将在屏幕上向上滑动(或者您无法为其设置动画),然后您可以像对待它一样将其解除。
答案 1 :(得分:0)
在黑暗中狂野射击,但我想你可以通过在你的孩子控制器中调用UIPageVieWController
来达到你的self.parentViewController
。
然后你可以解雇它(如果它是模态呈现的)或弹出它。
答案 2 :(得分:0)
我刚刚意识到我在xib文件中有2个视图,并且IBAction连接到错误的视图。我一直在复制和粘贴按钮,标签等。在其中一个贴纸上,我必须复制粘贴整个视图。我删除了它并使用了以下命令,它确实关闭了视图:
[self dismissViewControllerAnimated:YES completion:nil];