【发布时间】:2010-08-18 10:12:27
【问题描述】:
我需要在主界面上方放置一个信息屏幕,但我需要它是 alpha'd 以便您可以看到它下面的界面。但是,当我在屏幕上触摸时,下面的界面仍在运行。
拦截触摸事件以使其不通过的最佳方法是什么?我尝试添加屏幕大小的自定义 UIButton,但这也不起作用:(
不幸的是,这里发布的代码太多了。视图长达数百行,但重要的是添加覆盖的子视图,如下所示:
InfoScreen *infoScreen = [[UIView alloc] initWithFrame:self.view.frame];
UIButton *invisibleButton = [UIButton buttonWithType:UIButtonTypeCustom];
invisibleButton.frame = self.view.frame;
[self.view addSubview:invisibleButton];
[self.view addSubview:infoScreen];
我在下面的视图中使用 touchesBegan、touchesMoved、touchesEnded 和 touchesCancelled。这可能是触摸通过的原因吗?
谢谢!
:-乔
【问题讨论】:
标签: objective-c iphone cocoa-touch uiview uibutton