iOS - UIPageControl 上的 UIButton 不起作用

iOS - UIButton on UIPageControl not working(iOS - UIPageControl 上的 UIButton 不起作用)
本文介绍了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 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)