禁止用户在视图IOS中交互 [英] Disable user interact in a view IOS

查看:229
本文介绍了禁止用户在视图IOS中交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码禁用和启用视图。

I am disabling and enabling a view using the following code....

[self.view setUserInteractionEnabled:NO];
[self.view setUserInteractionEnabled:YES];

如果我这样做,所有的subview也受到影响...所有都禁用,我只做特定的观点?是否可能?

If I do like this, all it subviews also got affected... All are disabled, how do I do only for particular view? Is it possible?

推荐答案

这是完全一样的,假设你的另一个视图是一个成员或者你可以迭代通过 self.view 的子视图数组,如下所示:

It's exactly the same, assuming your other view is either a member or you can iterate through self.view's array of subviews, like so:

MyViewController.h >

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

这篇关于禁止用户在视图IOS中交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆