我正在使用以下代码禁用和启用 View ....
[self.view setUserInteractionEnabled:NO];
[self.view setUserInteractionEnabled:YES];
如果我这样做,它的所有 subview 也会受到影响...所有都被禁用,我该如何只针对特定 View ?可能吗?
最佳答案
完全一样,假设您的其他 View 是成员,或者您可以遍历 self.view
的 subview 数组,如下所示:
MyViewController.h
UIView* otherView;
MyViewController.m
otherView.userInteractionEnabled = NO; // or YES, as you desire.
或者:
for (int i = 0; i < [[self.view subviews] count]; i++)
{
UIView* view = [[self.view subviews] objectAtIndex: i];
// now either check the tag property of view or however else you know
// it's the one you want, and then change the userInteractionEnabled property.
}
关于iphone - 在 View IOS 中禁用用户交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12213663/