【发布时间】:2010-02-21 09:17:12
【问题描述】:
嗨~我有一个问题。 ^^
如何在 UIWebView(或 UITextView)上获取“选定文本”?
我想复制“选定的文本”而不复制/粘贴弹出视图。
1) 我删除了...复制/粘贴视图。 (成功了~)
UIMenuController *theMenu = [UIMenuController sharedMenuController];
[theMenu setMenuVisible:NO];
[theMenu update];
2.强制复制“选定文本”(失败)
copyController.h -------------
@interface copyController : UIViewController <UIWebViewDelegate>
{
UIWebView *WebView;
}
copyController.m ------------
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
// ----------> here !!!!!
// I'd like to forced copy "selected text" without copy/paste popup-view
// ** How can i get selected text ???**
return [super canPerformAction:action withSender:sender];
}
- (void)copy:(id)sender
{
UIPasteboard *board = [UIPasteboard generalPasteboard];
NSLog(@"SENDER : copied : %@",board.string);
}
如何在 canPerformAction 中复制文本。 ?
我要复制“选定文本”的原因只是为了通过更改颜色和字体来装饰文本。
谢谢你~
【问题讨论】:
标签: iphone cocoa-touch copy-paste uipasteboard