我对如何使用故事板和自定义 initaliziers 感到困惑。
我需要在 UIPageViewController 上调用 initWithTransitionStyle。
但是如果故事板为我创建了 UIPageViewController 怎么办?
通过调试,我可以看到在我的 UIPageViewController 上调用了 initWithCoder。
我对如何使用故事板和自定义 initaliziers 感到困惑。
我需要在 UIPageViewController 上调用 initWithTransitionStyle。
但是如果故事板为我创建了 UIPageViewController 怎么办?
通过调试,我可以看到在我的 UIPageViewController 上调用了 initWithCoder。
According to the documentation, there is only one transition style:
Transition Styles
Styles for the page-turn transition.
enum { UIPageViewControllerTransitionStylePageCurl = 0 }; typedef NSInteger UIPageViewControllerTransitionStyle;
Constants
UIPageViewControllerTransitionStylePageCurl
Page curl transition style. When the page curl transition style is specified, the page view controller displays a page-turning animation when transitioning between view controllers. If a data source is specified, the animation follows the user’s finger during a navigation gesture. Available in iOS 5.0 and later. Declared in UIPageViewController.h.
When they introduce others, I expect you will be able to define them in interface builder.
SecondViewController* bvc = [[SecondViewController alloc] init];
[UIView transitionWithView:self.view.window
duration:1.0f
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
[self.navigationController pushViewController:bvc animated:NO];
}
completion:NULL];
[self.navigationController pushViewController:bvc animated:YES];
如果您正在使用情节提要(也就是将 UIPageViewController 放到情节提要上),它已经初始化,所以我不确定您为什么需要初始化它。
如果您只想更改过渡样式、导航方向、页面间距等,这些都是“属性检查器”选项卡中的选项。
我找到了问题的解决方案:这里是:在appdelegate.m
文件中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
CountBookViewController *bc = [[CountBookViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
[bc awakeFromNib];
self.window.rootViewController = bc;
[self.window makeKeyAndVisible];
return YES;
}