美文网首页
UIMenuController 遇到的坑

UIMenuController 遇到的坑

作者: AllureJM | 来源:发表于2017-02-27 15:22 被阅读0次

    [self becomeFirstResponder];//必须成为第一响应者

    UIMenuController *menuController = [UIMenuController sharedMenuController];

    UIMenuItem *resetMenuItem = [[UIMenuItem alloc] initWithTitle:@"删除" action:@selector(deleteItemClicked:)];

    NSAssert([self becomeFirstResponder], @"Sorry, UIMenuController will not work with %@ since it cannot become first responder", self);

    [menuController setMenuItems:[NSArray arrayWithObject:resetMenuItem]];

    [menuController setTargetRect:buttonFrame inView:_svContainer];

    [menuController setMenuVisible:YES animated:YES];

    ios项目中在会用到系统的menu菜单这样的小功能,但是一定要加上[self becomeFirstResponder];这句代码,因为不成为第一响应者,他不会work

    而我在项目中在Debug环境下没有事,但是在Relese环境下竟然不走。这一点目前很迷茫

    相关文章

      网友评论

          本文标题:UIMenuController 遇到的坑

          本文链接:https://www.haomeiwen.com/subject/ibmzwttx.html