ios - 在 VC 堆栈中快速移动 UIButton

标签 ios objective-c iphone xcode swift

我想知道如何在 VC 堆栈中向上移动 UIButton?

我的问题:

在我的 VC 中,我添加了一个页面 Controller View ,以便在图像之间滑动。但问题是当我这样做时,按钮卡在添加的页面 Controller View 后面。

我的 VC 看起来像: enter image description here

添加页面 View Controller 时我的代码:

self.pageViewController.setViewControllers(viewControllers as [AnyObject], direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: nil)

        self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)

        self.addChildViewController(self.pageViewController)
        self.view.addSubview(self.pageViewController.view)
        self.pageViewController.didMoveToParentViewController(self)

这将导致按钮不显示/卡在页面 View Controller 后面。

我已经尝试在 Root View 和该 View 之前的按钮下添加第二个 UIView,然后通过以下方式将页面 View Controller 作为 subview 添加到该新 View :self.MyNewSubView.addSubview(self.pageViewController.查看)

这几乎行得通。该按钮显示在页面 View Controller 前面,但页面 View Controller 的自动布局变得困惑,因为它包含带有图像(放大/缩小)的 uiscroll View 。

我还尝试将 CGRectMake 设置为例如 CGRectMake(0,50),这有点管用。但问题是肖像中的大图像在底部被剪裁。

所以我想做的是在添加页面 View Controller 后将按钮推到堆栈上。

提前致谢

最佳答案

你可以要求你当前的 View bringSubviewToFront(button)

关于ios - 在 VC 堆栈中快速移动 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31632715/

相关文章:

ios - 如何将一个 SKPhysicsBody 固定到另一个而不同时掉落

c# - 为 Windows Mobile、Android 和 iPhone 开发 C# 应用程序

ios - 如何将符合具有关联类型的协议(protocol)的不同类型添加到集合中?

ios - UIView 编程约束不起作用

iphone - 地理围栏指标与位置服务指标

ios - 将 CGPDFDocumentRef 添加到 NSDictionary 或 NSArray

iphone - 通过自动化脚本在仪器 iOS 标准输出上自定义日志

iPhone 使用另一个 View 添加 View

ios - Facebook SDK iOS

ios - 删除 UICollectionView 底部的插入间距