iOS - UIPageControl上的UIButton不能正常工作 [英] iOS - UIButton on UIPageControl not working

查看:87
本文介绍了iOS - UIPageControl上的UIButton不能正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 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不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆