views:

12

answers:

1

I need to put up an info screen above the main interface, but I need it to be alpha'd so you can see the interface underneath it. However, when I touch across the screen, the interface underneath is still running.

What is the best method for intercepting the touch events so they don't pass through? I tried to add a custom UIButton the size of the screen, but that didn't work either :(

There is too much code to post here unfortunately. The view is hundreds of lines long, but the important bit is adding the overlayed subview, which is like this:

InfoScreen *infoScreen = [[UIView alloc] initWithFrame:self.view.frame];
UIButton *invisibleButton = [UIButton buttonWithType:UIButtonTypeCustom];
invisibleButton.frame = self.view.frame;

[self.view addSubview:invisibleButton];
[self.view addSubview:infoScreen];

I am using touchesBegan, touchesMoved, touchesEnded and touchesCancelled in the view below. Is this possibly why the touches are getting through?

Thanks!

:-Joe

A: 

If you want to stop everything from responding (for example for a time-based block), you can use

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];

and

[[UIApplication sharedApplication] endIgnoringInteractionEvents];

It won't work if you need a touch to cancel this state ;-). In that case, a transparent UIView on top of your background will get the job done. If it doesn't, post some code.

PS: Your accept rate is very low. If an answer helps you, please vote up and accept the best answer. You might also revisit your older questions.

Eiko
Unfortunately I can't do that, because I need to be able to interact with the view I have added over the top. I have tried setting userInteractionEnabled to NO, but since the overlayed view is a subview, then the interaction gets disabled on that too. I will post some code above. Thanks.P.S. I will revisit old questions to see if I can mark some answered. Thanks.
Joe