iOS - UIPageControl 上的 UIButton 不工作

标签 ios uiviewcontroller uibutton uistoryboard uipagecontrol

我正在使用 UIPageControl 作为我应用程序不同页面( View Controller )之间的指示器。在每个 View Controller 中,我需要在 UIPageControl 的左上角有一个不同的按钮。如果我在每个 View Controller 的那个位置放置一个 UIButton,我会在 UIPageControl 上看到它,但按钮不响应触摸事件。有什么我想念的吗?或者有其他选择吗?谢谢。

最佳答案

我猜页面控件和 View Controller View 都是同一 View 的 subview 。在这种情况下,按钮绘制在 View Controller View 边界之外。这是默认允许的,但它确实有副作用,即无法点击按钮,因为 superview 不处理触摸。

您应该在“ super ” View Controller (拥有包含页面控件和 subview Controller 的 Root View 的 Controller )拥有的页面控件上拥有按钮。然后,当一个按钮被点击时,它应该告诉 subview Controller 它可以采取适当的行动。

关于iOS - UIPageControl 上的 UIButton 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21355809/

相关文章:

c++ - 如何动态更改按钮标题(当 bool 具有特定属性时)

ios - UIButton 导致崩溃

php - NSURL with\n 调用 php 文件

ios - iOS8 中 iPhone 应用程序启动图像的大小和命名

ios - 在选择一行之前,函数无法正常工作

ios - 将数据从 uiview 传递到 uiviewcontroller

ios - map 应用程序不工作

ios - 如何使用 Swift 检测 iOS 应用何时出现在前台?

uiviewcontroller - UIModalTransitionStyle和UIModalPresentationStyle有什么区别?

ios - CustomCell (TableView) 中的 Swift Button 将参数传递给 targetMethod