我想使用UIPageViewController和拖车按钮(next和preve)来显示7个具有不同内容的View Controller,这是我在实现UIPageViewController后的故事板。
我的问题是如何将这些视图控制器放在UIPageViewController中?
答案 0 :(得分:2)
Swift中的答案:
调用setViewControllers方法,在你的UIPageVC实例的viewDidLoad中定义你的第一个VC,方向等:
<div class="header row">
<div class="large-12 columns frontpage-header-content">
<div class="snirky-snark-box">
<h4>Vi arbeider med å bygge kompetanse, spre kunnskap og positiv energi i kreftsaken</h4>
<button type="button" class="button">Støtt kreftsaken</button>
</div>
<div class="frontpage-header-image">
<img src="http://placehold.it/800x150">
</div>
</div>
<div class="header-title-bar">
<div class="row">
<div class="large-12 columns">
<div class="title-bar">
<div class="title-bar-left">
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/menu-icon.svg">
<button class="menu-icon" type="button" data-open="offCanvasLeft"></button>
<span class="title-bar-title">Meny</span>
</div>
<div class="title-bar-right">
<span class="title-bar-title">Støtteforeningen for Kreftrammede</span>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.header -->
使用UIPageViewControllerDataSource协议方法定义当前viewController之前和之后的页面,以及视图控制器计数和索引。
override func viewDidLoad() {
super.viewDidLoad()
dataSource = self
let vc = storyboard!.instantiateViewController(withIdentifier: "whatever storyboard id your first VC is")
setViewControllers([vc],
direction: .forward,
animated: false,
completion: nil)
}