Closed AaronZhang2015 closed 8 years ago
if (target.events & controlEvents) { UIControlEvents newEvent = target.events & (~controlEvents); if (newEvent) { [self removeTarget:target action:@selector(invoke:) forControlEvents:target.events]; target.events = newEvent; [self addTarget:target action:@selector(invoke:) forControlEvents:target.events]; } else { [self removeTarget:target action:@selector(invoke:) forControlEvents:target.events]; [removes addObject:target]; } }
第一个if不是已经判断是不是同一个事件了么,第二行是什么意思
events 是按位来处理的。 第一行判断的是,当前 events 是否和 controlEvents 有交集,第二行是把 controlEvents 排除掉,还剩几个 event。
if (target.events & controlEvents) { UIControlEvents newEvent = target.events & (~controlEvents); if (newEvent) { [self removeTarget:target action:@selector(invoke:) forControlEvents:target.events]; target.events = newEvent; [self addTarget:target action:@selector(invoke:) forControlEvents:target.events]; } else { [self removeTarget:target action:@selector(invoke:) forControlEvents:target.events]; [removes addObject:target]; } }
第一个if不是已经判断是不是同一个事件了么,第二行是什么意思