iOS - UIPageControl 上的 UIButton 不起作用

2023-07-07移动开发问题
1

本文介绍了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 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

恢复游戏 cocos2d
Resume game cocos2d(恢复游戏 cocos2d)...
2024-08-12 移动开发问题
6

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

[ios.cocos2d+box2d]如何禁用自动旋转?
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)...
2024-08-12 移动开发问题
7

从 Documents 目录存储和读取文件 iOS 5
Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)...
2024-08-12 移动开发问题
9

如何在 cocos2d 环境之外实现 cocos2d 游戏的虚拟摇杆?
How can I implement a virtual joystick for a cocos2d game outside the cocos2d environment?(如何在 cocos2d 环境之外实现 cocos2d 游戏的虚拟摇杆?)...
2024-08-12 移动开发问题
13