iPhone +检测禁用的 UIControl 的点击

发布于 2024-08-20 07:10:42 字数 296 浏览 4 评论 0原文

我正在为一个现有应用程序开发应用程序内购买。场景就像我在应用程序中有一个功能(包含 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梨涡 2024-08-27 07:10:42

通过制作如下按钮,将不可见按钮放在文本区域上:

    UIButton* button = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
    button.frame =CGRectMake(your parameters here);
    button.showsTouchWhenHighlighted=YES; // handy for debugging
    [button addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside];

并将其添加为子视图。根据您想要实现的目标以及 UITextField 包含的内容,您需要将其添加到的内容可能会有所不同。

Put an invisible button over the text area by making a button like this:

    UIButton* button = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
    button.frame =CGRectMake(your parameters here);
    button.showsTouchWhenHighlighted=YES; // handy for debugging
    [button addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside];

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.

闻呓 2024-08-27 07:10:42

据我所知,禁用视图的子视图也被禁用,所以我猜你的“功能”是禁用视图。
您可以尝试将 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.

伴我老 2024-08-27 07:10:42

直接检测禁用的 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.

卷耳 2024-08-27 07:10:42

用户如何知道按下禁用按钮?您最好提供一个非禁用按钮,清楚地表明按下它时会发生什么。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文