1.添加控件到View镀脂,然后設(shè)置self.lab.userInterface = YES;
2.添加手勢(shì) [self.lab addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labClick)]];
3.設(shè)置具體的點(diǎn)擊事件啥供,[self becomeFirstResponser];標(biāo)示view可以處理事件,這個(gè)很重要, @"setTargetRect"設(shè)置target 有兩種寫(xiě)法奶段,一種是[menu setTargetRect:self.lab.bounds inView:self.lab];
另一種是[menu setTargetRect:self.frame inView:self.superview];?
4.實(shí)現(xiàn)具體的點(diǎn)擊事件
5.最重要的一點(diǎn)就是設(shè)置 成為第一響應(yīng)者,因?yàn)閘ab在控制器的view上卖宠,那么就應(yīng)該讓view成為第一響應(yīng)者,這句話(huà)一定要寫(xiě)忧饭,不寫(xiě)的話(huà),會(huì)不執(zhí)行彈出UIMenuContoller(誰(shuí)是第一響應(yīng)者筷畦,就在哪里寫(xiě)這個(gè)词裤,如果是自定義一個(gè)iamge,給他設(shè)置手勢(shì)的話(huà)鳖宾,應(yīng)該把這句話(huà)添加到image的類(lèi)中)
結(jié)束語(yǔ):這個(gè)是給lab添加一個(gè)menu吼砂,也可以給tableviewContoller添加,方法和本文相同鼎文。