UIMenuController控件的使用
由于需求临时变更,同事写的自定义MenuController用不了了,只好用系统的MenuController,但在完成以下代码后,死活都调不出popMenu来:
UIMenuController *popMenu = [UIMenuController sharedMenuController];
UIMenuItem *item1 = [[UIMenuItem alloc] initWithTitle:@”1″action:@selector(menuItem1Pressed:)];
UIMenuItem *item2 = [[UIMenuItem alloc] initWithTitle:@”2″action:@selector(menuItem2Pressed:)];
UIMenuItem *item3 = [[UIMenuItem alloc] initWithTitle:@”3″action:@selector(menuItem3Pressed:)];
UIMenuItem *item4 = [[UIMenuItem alloc] initWithTitle:@”4″action:@selector(menuItem4Pressed:)];
NSArray *menuItems = [NSArray arrayWithObjects:item1,item2,item3,item4,nil];
[popMenu setMenuItems:menuItems];
[popMenu setArrowDirection:UIMenuControllerArrowDown];
[item4 release];
[item3 release];
[item2 release];
[item1 release];
[popMenu setTargetRect:CGRectMake(162,195,0,0) inView:self.dialView];
[popMenu setMenuVisible:YES animated:YES];
后来在StackOverFlow上看到这个问题,同时也在cocoachina上找到相应的方法,原来要想显示弹出菜单,必须实现3个方法,缺一不可:
转载:http://blog.sina.com.cn/s/blog_8280f5ec0101h7ej.html