iPhone +检测禁用的 UIControl 的点击
我正在为一个现有应用程序开发应用程序内购买。场景就像我在应用程序中有一个功能(包含 UITextField 控件),该功能最初被禁用,当用户点击该 UITextField 时,它会显示解锁和购买该功能的消息,一旦完成,UITextField 将启用。
但问题是,由于 UITextField 最初被禁用,我无法检测到任何点击,因此我无法获得任何可以为应用内购买功能编写代码的事件。
或者
如果无法检测到禁用的 UIControl 的点击,还有什么其他选项可以实现上述功能。
请帮忙。
问候, 普拉克
I am developing In App purchase for one existing application. Scenario is something like I have a feature in application (which contain UITextField control), which is initially disabled and when user taps on that UITextField, it shows the message to unlock and buy that feature and once its done, UITextField will be enable.
But the problem is that since UITextField is disabled initially, I am not able to detect any tap on that, so I am not able to get any event where I can code for In App purchase functionality.
OR
If its not possible to detect the tap of disabled UIControl, what can be other option to achieve the above functionality.
Please help.
Regards,
Praik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
通过制作如下按钮,将不可见按钮放在文本区域上:
并将其添加为子视图。根据您想要实现的目标以及 UITextField 包含的内容,您需要将其添加到的内容可能会有所不同。
Put an invisible button over the text area by making a button like this:
and adding it as a subview. Depending on what you're trying to achieve and what your UITextField is contained in, what you need to add it to may differ.
据我所知,禁用视图的子视图也被禁用,所以我猜你的“功能”是禁用视图。
您可以尝试将 UIControl 放在未禁用的视图上(例如 UIWindow 或任何子视图)并将其放在顶部。
不是 100% 确定,但我认为它应该有效。
Of what I remember, subviews of disabled views are also disabled, so I guess your "feature" is a disabled view.
You can try to put your UIControl on a view which is not disabled (the UIWindow for example, or any subview) and bring it on top.
Not 100% sure but i think it should work.
直接检测禁用的
UIControl
的点击并不容易,除非您将其子类化并挂钩-touchesXXXXX:withEvents:
方法。但是,您可以在禁用的 UIControl 之上放置一个活动且透明的
UIControl
来接管水龙头。购买完成后移除透明控件。It is not easy to detect taps of disabled
UIControl
directly unless you subclass it and hook the-touchesXXXXX:withEvents:
methods.However, you can layer an active and transparent
UIControl
on top of the disabled one to takeover the tap. Remove the transparent control once the purchase is done.用户如何知道按下禁用按钮?您最好提供一个非禁用按钮,清楚地表明按下它时会发生什么。
How is a user going to know to press a disabled button? You are better off offering a non-disabled button that makes clear what will happen when you press it.