English 中文(简体)
iPhone + detect tap of disabled 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

最佳回答

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.

问题回答

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.

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.





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签