gpt4 book ai didi

ios - uipageViewController 没有加载 y=0 的 View

转载 作者:行者123 更新时间:2023-11-28 06:48:16 25 4
gpt4 key购买 nike

我正在使用 pagevew Controller 来实现抽屉功能。一切正常,但第一次加载 View 时,它会留下状态栏的空间并在状态栏下开始。我需要从 y= 0 显示 View

private func setupPageViewController() {
pageViewController = UIPageViewController(transitionStyle: UIPageViewControllerTransitionStyle.Scroll, navigationOrientation: UIPageViewControllerNavigationOrientation.Horizontal, options: nil)
pageViewController.dataSource = self
pageViewController.delegate = self
pageViewController.setViewControllers([stackPageVC[stackStartLocation]], direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: nil)
var pageViewControllerY: CGFloat = 0
var pageViewControllerH: CGFloat = 0
if navigationBarShouldNotExist {
pageViewControllerY = 0
pageViewControllerH = Constants.ScreenHeight
} else {
pageViewControllerY = 0
pageViewControllerH = Constants.ScreenHeightWithoutStatusBar
}
pageViewController.view.frame = CGRect(x: 0, y: pageViewControllerY, width: Constants.ScreenWidth, height: pageViewControllerH)


pageViewController.view.backgroundColor = UIColor.clearColor()
addChildViewController(pageViewController)
view.addSubview(pageViewController.view)
pageViewController.didMoveToParentViewController(self)

}

我试过

for v: UIView in pageViewController.view.subviews {
if (v is UIScrollView) {
let scroll = v as! UIScrollView
scroll.setContentOffset(CGPointMake(0, 0), animated: false)
print("----")
}
}

对于抽屉功能,我正在使用这个库 drawer

它是这样显示的showing like this并希望像这样显示 want to display like this

一件事是,如果我触摸屏幕上的任何地方,它就会恢复正常

最佳答案

只需选择放置 pageviewcontroller 的 Storyboard,在右侧有一个选项 UnderTopBar 只需取消选择该选项即可。你会得到解决方案。或者你可能只是对 toplayout 设置了约束,所以将它设置为从 toplayout 到 view

关于ios - uipageViewController 没有加载 y=0 的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35645180/

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