为了显示帮助视图,我放了一个后面有一些UIButtons的UIImageView。如何禁用这些按钮的用户交互?如果我触摸这张图片,按钮在后面,它们会响应触摸事件。
图片背景代码:
self.helpBackground = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
self.helpBackground.backgroundColor = [UIColor colorWithWhite:0 alpha:0.75];
self.helpBackground.hidden = YES;
[self.view addSubview:self.helpBackground];我使用了self.helpBackground.userInteractionEnabled = NO;但不起作用。
谢谢。
发布于 2014-09-03 21:58:07
在您的helpView(imageview)中保留一个标记,并添加以下代码
for (UIView *view in self.view.subviews) {
if (view.tag != yourViewTag) {
view.userInteractionEnabled = NO;
}
} 在删除帮助屏幕之后,使用以下代码
for (UIView *view in self.view.subviews) {
view.userInteractionEnabled = YES;
} https://stackoverflow.com/questions/25645744
复制相似问题