iOS UIMenuItem弹出菜单
来源:互联网 发布:360网络防火墙逆战卡枪 编辑:程序博客网 时间:2024/04/29 20:53
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(pressClick:)];
[self.view addGestureRecognizer:longPress];
self.view.userInteractionEnabled = YES;
{
[self becomeFirstResponder];
[self popMemu];
}
- (BOOL)canBecomeFirstResponder
{
return YES;
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
// 自定义方法时才显示对就选项菜单,即屏蔽系统选项菜单
if (action == @selector(copyClick) || action == @selector(deleteClick) || action == @selector(moveClick))
{
return YES;
}
return NO;
}
- (void)popMemu
{
// @selector()括号中为该按钮触发的方法,该方法必须在UIVIewContrller中进行声明,就是投向的view所绑定的viewController类中必须实现这个方法
UIMenuItem *menuItem_1 = [[UIMenuItem alloc] initWithTitle:@"复制" action:@selector(copyClick)];
UIMenuItem *menuItem_2 = [[UIMenuItem alloc] initWithTitle:@"删除" action:@selector(deleteClick)];
UIMenuItem *menuItem_3 = [[UIMenuItem alloc] initWithTitle:@"移动" action:@selector(moveClick)];
UIMenuController *menuController = [UIMenuController sharedMenuController];
menuController.menuItems = [NSArray arrayWithObjects:menuItem_1, menuItem_2, menuItem_3, nil];
// touchpos_x, touchpos_y分别为长按那点的x和y坐标 self.view为将要展示弹出框的视图
CGFloat touchpos_x = 40.0;
CGFloat touchpos_y = 100.0;
[menuController setTargetRect:CGRectMake(touchpos_x, touchpos_y, 100.0, 40.0) inView:self.view];
[menuController setMenuVisible:YES animated:YES];
}
- (void)copyClick
{
NSLog(@"copy");
}
- (void)deleteClick
{
NSLog(@"delete");
}
- (void)moveClick
{
NSLog(@"move");
}
- iOS UIMenuItem弹出菜单
- 关于UIMenuController的使用 弹出菜单UIMenuItem
- 关于UIMenuController的使用 弹出菜单UIMenuItem
- 关于UIMenuController的使用 弹出菜单 ios开发 iphone开发 UIMenuItem
- UIMenuItem 文字选择菜单
- UIMenuController IOS 弹出菜单
- ios 底部弹出框菜单
- ios alert对话框 弹出菜单
- iOS-YHPopMenu(仿微信"+"弹出菜单)
- UIMenuController和UIMenuItem,即iOS剪贴板
- iOS 控制 UIMenuItem 的显示和隐藏
- IOS实现弹出菜单效果MenuViewController(背景 景深 弹出菜单)
- IOS实现弹出菜单效果MenuViewController(背景 景深 弹出菜单)
- iOS tableView多选,长按弹出菜单
- 弹出菜单
- 弹出菜单
- 弹出菜单
- 自定义UIMenuItem
- C总结-第二章 符号(2/6)
- 安装 rubygems
- 模板之非类型模板参数
- IOS为什么比Android流畅
- MTK 如何用ADB 修改和显示GPIO状态
- iOS UIMenuItem弹出菜单
- zigbee 5:远程开关
- 《Effective Modern C++》Item 1总结
- Performing Network Operations - Parsing XML Data
- android小功能实现之发送短信
- Android之ListView滚动到底后自动加载数据
- Mysql安装与启动的问题
- wait study
- 模板之组合技术