Reputation: 261
I have a large UILabel
which I am using to cover a bunch of buttons while I do something else.
All I have set initially is myLabel.hidden = YES;
so you can't see the UILabel
but the UIButtons
(below it) won't work anymore.
Is there another setting for the UILabel
I can use to allow touches to go "through it" when it is hidden? Thanks.
Upvotes: 1
Views: 2616
Reputation: 12389
I think you should hide your buttons instead of covering them with a label.
[yourButton setHidden = YES];
[yourButton2 setHidden = YES];
...
Upvotes: 0
Reputation: 106
[myLabel setUserInteractionEnabled:NO]. Even if is hidden, your label will get the touches anyway. You have to disable that to achieve what u want.
Upvotes: 0
Reputation: 9544
The simplest thing to use as a general way to hide or cover things just a straight UIView. set:
[myCoverView setUserInteractionEnabled:YES];
and it will intercept touches and block touches to the buttons below it.
It should stop blocking touches when you hide it or turn the alpha to 0.0; You can always siwtch the covering views interaction to:
[myCoverView setUserInteractionEnabled:NO];
and touches will pass through it.
If there is some reason that you need the UILabel these methods will work with it also.
Upvotes: 0
Reputation: 10393
I am not sure why a hide is stopping the touch events on buttons. Anyways you can explicitly bring the buttons to foreground by the following calls.
[self bringSubviewToFront:button];
Upvotes: 0
Reputation: 4066
You can use addSubView
and removeFromSuperview
methods :
When you want to hide your UIButton with your UILabel :
[self.view addSubview:myLabel];
and the contrary :
[myLabel removeFromSuperview];
Upvotes: 0
Reputation: 720
why use a UILabel to cover your buttons.
just set
UIButton *button;
[button setUserInteractionEnabled:NO];
or
[button setUserInteractionEnabled:YES];
Upvotes: 2