我在 中创建了一个菜单UITableViewCell
,它UIMenuController
只有两个项目。但是当我运行它时,这个菜单显示了很多项目,似乎是 ios 默认菜单项,如屏幕截图所示:
如何删除这些项目并只显示我定义的项目?谢谢。
这是我的代码:
- (id)initWithComment:(DSComment *)comment { self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"comment"]; UILabel *contentLabel=[[UILabel alloc] initWithFrame:CGRectMake(10, 45, 300, 0)]; contentLabel.text=comment.message; [self.contentView addSubview:contentLabel]; 回归自我; } - (BOOL) canBecomeFirstResponder { 返回是; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [自己成为FirstResponder]; UIMenuController *menu = [UIMenuController sharedMenuController]; UIMenuItem *like = [[UIMenuItem alloc] initWithTitle:@"Like" action:@selector(like:)]; UIMenuItem *reply = [[UIMenuItem alloc] initWithTitle:@"Replay" action:@selector(reply:)]; [菜单 setMenuItems:[NSArray arrayWithObjects:like, reply, nil]]; [菜单 setTargetRect:CGRectMake(0, 0, 0.0f, 0.0f) inView:self]; [菜单 setMenuVisible:YES 动画:YES]; }