iphone: how to block touches while showing some UIView
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;
精彩评论