开发者

iphone: how to block touches while showing some UIView

开发者 https://www.devze.com 2023-01-13 13:46 出处:网络
my current scenario is this -> i am showing a view controller that has a button. when i click that button a small view opens. now what i want. when th开发者_如何学运维at view is shown i don\'t want us

my current scenario is this -> i am showing a view controller that has a button. when i click that button a small view opens. now what i want. when th开发者_如何学运维at view is shown i don't want user to touch below that ( even in navigation bar's back button ). the same thing which UIAlertView does. how i can achieve that thing with my custom view ??

Please suggest.


You could cover the current view with a different UIView which would take the touches and stop them. Here's some code to overlay a UIView which is black (and slightly transparent) to block touches.

UIView *blackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; 
blackView.backgroundColor = [UIColor blackColor];
blackView.alpha = 0.8f;
[self.view addSubview:blackView]; 

UPDATE

To disable the back button, try using the following.

self.navigationItem.leftBarButtonItem.enabled = NO;
0

精彩评论

暂无评论...
验证码 换一张
取 消