我使用 UIPageControl
作为应用程序不同页面(视图控制器)之间的指示器.在每个视图控制器中,我需要在 UIPageControl 的左角有一个不同的按钮.如果我在每个视图控制器的该位置放置一个 UIButton
,我会在 UIPageControl
上看到它,但按钮不会响应触摸事件.有什么我想念的吗?或者有没有其他方法可以做到这一点?谢谢.
I am using UIPageControl
as indicator between different page (view controllers) of my application. In each of the view controllers, I need to have a different button on the left corner on the UIPageControl. If I place a UIButton
at that position on each of the view controllers, I see it on the UIPageControl
but the buttons do not respond to the touch event. Is there something I am missing? Or is there an alternative to do this? Thanks.
我猜页面控件和视图控制器视图都是同一个视图的子视图.在这种情况下,按钮被绘制在视图控制器视图边界之外.默认情况下允许这样做,但它确实具有无法点击按钮的副作用,因为超级视图不处理触摸.
I guess the page control and the view controller view are both subviews of the same view. In this case, the button is drawn outside of the view controllers view bounds. This is allowed by default, but it does have the side effect that the button can't be tapped on as the superview doesn't handle the touch.
您应该拥有超级"视图控制器(拥有包含页面控件和子视图控制器的根视图的控制器)拥有的页面控件上的按钮.然后,当一个按钮被点击时,它应该告诉子视图控制器它可以采取适当的行动.
You should have the buttons on the page control owned by the 'super' view controller (the controller that owns the root view containing the page control and the child view controllers). Then, when a button is tapped it should tell the child view controller about it so that it can take the appropriate action.
这篇关于iOS - UIPageControl 上的 UIButton 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!