iphone:如何在显示一些 UIView 时阻止触摸

发布于 2024-09-16 10:03:59 字数 156 浏览 2 评论 0原文

我目前的情况是这样的 ->我正在展示一个带有按钮的视图控制器。当我单击该按钮时,会打开一个小视图。现在我想要什么。当显示该视图时,我不希望用户触摸该视图下方(即使在导航栏的后退按钮中)。 UIAlertView 做的事情是一样的。我如何用我的自定义视图实现这一目标?

请建议。

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 that 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泅渡 2024-09-23 10:03:59

您可以使用不同的 UIView 覆盖当前视图,该视图将接受触摸并停止触摸。
这里有一些代码覆盖 UIView ,它是黑色的(并且稍微透明)以阻止触摸。

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

更新

要禁用后退按钮,请尝试使用以下命令。

self.navigationItem.leftBarButtonItem.enabled = NO;

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文