UIView独占响应事件
2024-10-19 08:59:47
exclusiveTouch
A Boolean value that indicates whether the receiver handles touch events exclusively.
Setting this property to YES causes the receiver to block the delivery of touch events to other views in the same window. The default value of this property is NO.
一个布尔值,用来标示一个view独占触摸事件.
当把一个view中的exclusiveTouch设置成YES时,会致使这个window屏蔽掉其他的view触发响应事件.默认值是NO.
不用说就知道他的用处了,你不知道怎么回事么?以后你会懂的,测试人员给你提bug的时候你就知道了,上例子:
#import "RootViewController.h" @interface RootViewController () @property (nonatomic, strong) UIButton *button1;
@property (nonatomic, strong) UIButton *button2; @end @implementation RootViewController - (void)viewDidLoad
{
[super viewDidLoad]; _button1 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[self.view addSubview:_button1];
_button1.backgroundColor = [UIColor redColor];
[_button1 addTarget:self
action:@selector(buttonsEvent:)
forControlEvents:UIControlEventTouchUpInside]; _button1.exclusiveTouch = YES; _button2 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[self.view addSubview:_button2];
_button2.backgroundColor = [UIColor greenColor];
[_button2 addTarget:self
action:@selector(buttonsEvent:)
forControlEvents:UIControlEventTouchUpInside]; _button2.exclusiveTouch = YES;
} - (void)buttonsEvent:(id)sender
{
if (_button1 == sender)
{
NSLog(@"");
} if (_button2 == sender)
{
NSLog(@"");
}
} @end
最新文章
- JavaScript开发原生App模式能否突出重围?
- Selenium2+python自动化11-定位一组元素find_elements
- 在桌面chrome中调试android设备中的web页面
- 转:Java学习路线图,专为新手定制的Java学习计划建议
- 基于XMPP的即时通信系统的建立(四)— 组件介绍
- Time.deltaTime 含义和应用
- sort()排序 collections.sort();
- bzoj3065: 带插入区间K小值
- 关于退运美国转基因玉米含有MRI 162转基因成分的质疑
- C# 超级简单的Telnet (TcpClient)客户端
- 侯捷STL学习(四)--allocator和容器时间的实现关系
- WEB 小案例 -- 网上书城(二)
- SSH架构实现在线支付功能
- 国内开源社区巨作AspectCore-Framework入门
- Effective Java --使类和成员的可访问性最小化
- Win10恢复账户默认半透明头像
- Mac osx 启用和关闭root用户
- 对Property进行RACObserve
- Docker Dockerfile 基本结构详解
- 我在JS上解惑之路1