1

嗨,如何在从 Web 服务加载数据时禁用用户交互UiView

我使用以下行来禁用用户交互,但它不起作用。

self.view.userinteractionenabled=NO;

当网络服务结束时,我替换了YES 。

它不起作用,这会产生UINavigation问题。点击时会出现更多视图didSelectRow

4

2 回答 2

1
self.view.userinteractionenabled = NO;

这意味着用户无法触摸,self.view但如果页面有tabbarControllernavigationController用户可以触摸两者。

因此,当您的 Web 服务完成时,只需添加一个新UIView的 onwindow并将其从 superview 中删除即可。

添加方法:-

view = [[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];
[view setBackgroundColor:[UIColor blackColor]];
[view setAlpha:0.5];
AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
[appdelegate.window addSubview:view];

然后写

[view removeFromSuperview]; 

完成您的网络服务后。当然,您必须导入Appdelegate.h才能使用Appdelegate.

于 2012-09-22T06:30:24.003 回答
0

您正在设置 view 的 userInteraction ,因此它会禁用您的视图,但 navigationBack 按钮位于 window 上,因此请禁用窗口的 userInteraction 而不是禁用您的视图。

这是代码

AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
appdelegate.window.userInteractionEnabled = NO;
于 2012-09-22T10:08:35.103 回答