短篇小说:
从UIPageViewController(提供正确的DetailViewController)到UITableViewController,然后更改(在didSelectRowAtIndexPath上)UIPageViewController的DetailViewController和navigationController?.popViewControllerAnimated(true),显示正确的UIPageViewController和更改的DetailViewController,但整个视图被向下移动navigationBar的高度。点击屏幕将其发送到栏下(应该在哪里)。
长篇故事:
我在UIPageViewController中创建了自定义函数以返回所需的UIViewController
func viewDetailViewController(index: Int) -> DetailViewController? {
if let storyboard = storyboard, page = storyboard.instantiateViewControllerWithIdentifier("DetailViewController") as? DetailViewController {
// Setting the page variables that it stores
return page
}
return nil
}
我设置了一个代码(也在UIPageViewController中):
override func viewWillAppear(animated: Bool) {
if let viewController = viewDetailViewController(currentIndex) {
setViewControllers(
[viewController],
direction: .Forward,
animated: false,
completion: nil)
}
}
然后我在故事板中设置了一个条形按钮项目,并将其连接到所以它执行segue到UITableViewController。我想在单击单击时弹出一个viewContorller:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
self.pageViewController.currentIndex = indexPath.row
navigationController?.popViewControllerAnimated(true)
}
可能导致这种情况的原因是什么?