IOS自定义复制、拷贝功能
2013-07-11 18:31
726 查看
http://ios-iphone.diandian.com/post/2012-03-30/18195173
(1)、重写canBecomeFirstResponder方法
- (BOOL)canBecomeFirstResponder{
[super canBecomeFirstResponder];
return YES;
}
(2)、创建自定义UIMenuController
UIMenuItem *share = [[UIMenuItem alloc] initWithTitle:@"分享" action:@selector(share:)];
UIMenuItem *email = [[UIMenuItem alloc] initWithTitle:@"邮件" action:@selector(email:)];
UIMenuItem *print = [[UIMenuItem alloc] initWithTitle:@"打印" action:@selector(print:)];
UIMenuController *menu = [UIMenuController sharedMenuController];
[menu setMenuItems:[NSArray arrayWithObjects:share, email,print, nil]];
[menu setTargetRect:self.frame inView:self.superview];
[menu setMenuVisible:YES animated:YES];
(3)、判断显示哪个menu
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
[super canPerformAction:action withSender:sender];
if ( action == @selector(share:) || action == @selector(email:) || action == @selector(print:))
{
return YES;
}
else
{
return NO;
}
}
(1)、重写canBecomeFirstResponder方法
- (BOOL)canBecomeFirstResponder{
[super canBecomeFirstResponder];
return YES;
}
(2)、创建自定义UIMenuController
UIMenuItem *share = [[UIMenuItem alloc] initWithTitle:@"分享" action:@selector(share:)];
UIMenuItem *email = [[UIMenuItem alloc] initWithTitle:@"邮件" action:@selector(email:)];
UIMenuItem *print = [[UIMenuItem alloc] initWithTitle:@"打印" action:@selector(print:)];
UIMenuController *menu = [UIMenuController sharedMenuController];
[menu setMenuItems:[NSArray arrayWithObjects:share, email,print, nil]];
[menu setTargetRect:self.frame inView:self.superview];
[menu setMenuVisible:YES animated:YES];
(3)、判断显示哪个menu
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
[super canPerformAction:action withSender:sender];
if ( action == @selector(share:) || action == @selector(email:) || action == @selector(print:))
{
return YES;
}
else
{
return NO;
}
}
相关文章推荐
- (原创)iOS tableview系统左滑删除 左滑置顶 自定义左滑事件功能 输入框弹出
- iOS-自定义导航栏后侧滑返回功能失效
- iOS webview,WKWebView长按弹出框UIMenuController添加自定义功能
- iOS中使用ZBar扫描二维码自定义扫描界面功能
- IOS复制链接功能
- cocos2dx 实现文字的一键复制功能(IOS、Android)
- iOS中复制对象的用法及深拷贝和浅拷贝详解
- iOS开发进阶 - 用AVFoundation自定义视频录制功能
- iOS开发_iPhone 实现剪贴板操作_iPhone 复制粘贴功能
- iOS table简单实现增加移动和删除功能与自定义cell的实现
- iOS 为UILabel添加长按复制功能
- iOS封装定位类库,可自定义采集精度、超时时间、有效距离等功能
- 自定义的一个复制Transform组件的功能和一个控制物体显隐的功能
- 【iOS开发-62】自定义cell制作团购页面、顶部图片轮播、底部模拟加载更多功能,核心是练习代理模式
- iOS uiwebview 禁止弹出复制和黏贴功能
- iOS 内存管理~自定义对象的拷贝
- IOS 为UILabel和UIImageView添加长按复制功能
- 【iOS】UITableView Cell自定义单选功能
- 关于iOS uiwebview 禁止弹出复制和粘贴功能
- IOS中复制对象的用法及深拷贝和浅拷贝详解