开发者

Allow the user to select and copy text in a TTStyledTextLabel

开发者 https://www.devze.com 2023-01-26 18:07 出处:网络
I\'m not sure if this is a Three20 question or general ios/iphone (I\'m a noob in both areas.) I\'m currently using TTStyledTextLabel开发者_高级运维 in a table view to render styled content. Now I w

I'm not sure if this is a Three20 question or general ios/iphone (I'm a noob in both areas.)

I'm currently using TTStyledTextLabel开发者_高级运维 in a table view to render styled content. Now I would like to allow the user to select text and copy it. Checking the source for TTSTyledTextLabel I find this:

#pragma mark -
#pragma mark UIResponderStandardEditActions

- (void)copy:(id)sender {
  NSString* text = _text.rootNode.outerText;
  UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
  [pasteboard setValue:text forPasteboardType:@"public.utf8-plain-text"];
}

Which indicates that the label is ready to help with the actual copying. But I can't figure out how to make it allow for text selection.

Any ideas anyone?


Revisiting this years later... This isn't possible without rewriting the TTStyledText classes substantially.

0

精彩评论

暂无评论...
验证码 换一张
取 消