【问题标题】:UIPageViewController black background when sliding moreUIPageViewController 滑动多时背景黑
【发布时间】:2015-08-11 04:00:18
【问题描述】:

我正在使用 UIPageViewController 为我的 Objective-c 应用程序创建一些介绍幻灯片。

但是当我在第一张幻灯片中向左滑动更多或将最后一张幻灯片图像向右滑动更多时,我可以看到黑色背景。

如何防止用户在第一个滑块中向左滑动更多,在最后一个滑块中向右滑动更多。

非常感谢。

【问题讨论】:

  • 检查滚动视图内容宽度。它应该是 numberOfPages*screenWidth.First page frame x 应该是 0 .
  • 非常感谢..我不知道,它被称为反弹..我会检查它.. :)

标签: ios objective-c uipageviewcontroller uiviewanimation


【解决方案1】:

受@Munahil 启发的 Swift 3 代码:

class TutorialViewController : UIPageViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        ...

        // Add view to mask default black background of UIPageViewControllers
        let bgView = UIView(frame: UIScreen.main.bounds)
        bgView.backgroundColor = UIColor.blue
        view.insertSubview(bgView, at: 0)

        ...
    }

【讨论】:

    【解决方案2】:

    一个快速简单的解决方案是在您的UIpageView 后面放置一个UIView。这样,您将不会获得 black 背景。

    也看看这个stack overflow's question。它详细解释了如何禁用UIPageViewController

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-19
      • 1970-01-01
      • 2012-07-03
      • 1970-01-01
      • 1970-01-01
      • 2017-02-18
      • 2014-01-06
      • 1970-01-01
      相关资源
      最近更新 更多