我是可可语言的新手。我的要求: 点击菜单项时应打开Popover。我已动态创建菜单项。
1
NSMenu *theMenu =[[NSMenu alloc] initWithTitle:@"Contextual Menu"];
[theMenu insertItemWithTitle:@"Insert Comments" action:@selector(insertComments:) keyEquivalent:@"" atIndex:0];
2
- (IBAction)insertComments:(id)sender
{
[self.popover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxXEdge];
}
我收到此错误-[NSMenuItem bounds]: unrecognized selector sent to instance 0x600000ebdee0
什么应该发送给showItem的showRelativeToRect。