tags:

views:

256

answers:

4

Hello,

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

A: 

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.

Julien
A: 

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.

KennyTM
Hello, how can I remove the transparent control once the purchase is done
pratik
@pratik: `-removeFromSuperview`.
KennyTM
+1  A: 

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.

corprew
A: 

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.

Kendall Helmstetter Gelner