UIMenuController 遇到的坑

[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 遇到的坑)