How to fire uibarbuttonitem click event programmatically

后端 未结 8 2308
旧时难觅i
旧时难觅i 2020-12-05 05:41

I have created a UIActionSheet

UIActionSheet * action = [[UIActionSheet alloc]initWithTitle:@\"\"
                                                       


        
8条回答
  •  情深已故
    2020-12-05 05:54

    I've read the accepted answer and it is awfully DANGEROUS. you should never suppress such warnings in order to shortcut the path to your desired result!

    the safest way to do so:

    SEL selector=barButton.action;
    id target=barButton.target;
      if(selector && target){
         IMP imp = [target methodForSelector:selector];
         void (*func)(id, SEL) = (void *)imp;
         func(target, selector);
      }
    

    Please read the original post here: performSelector may cause a leak because its selector is unknown

提交回复
热议问题