启用UITextView的复制粘贴选项

时间:2013-04-19 04:58:30

标签: iphone ios6

我启用了UItextview的设置可编辑属性是,我可以在模拟器中运行时复制文本。但我无法复制粘贴iPhone设备中的文本..请有人解决我的问题

2 个答案:

答案 0 :(得分:0)

你能不能在UITextView上点击一下进行复制和粘贴。 另请查看此链接Enable copy and paste on UITextField without making it editable 希望这对你有所帮助。

答案 1 :(得分:0)

您是否尝试过使用“粘贴”方法? 以下是iOS指南中的示例:http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/UsingCopy,Cut,andPasteOperations/UsingCopy,Cut,andPasteOperations.html

- (void)paste:(id)sender {
    UIPasteboard *gpBoard = [UIPasteboard generalPasteboard];
    NSArray *pbType = [NSArray arrayWithObject:ColorTileUTI];
    ColorTile *theTile = [self colorTileForOrigin:currentSelection];
    if (theTile == nil && [gpBoard containsPasteboardTypes:pbType]) {
        NSData *tileData = [gpBoard dataForPasteboardType:ColorTileUTI];
        ColorTile *theTile = (ColorTile *)[NSKeyedUnarchiver     unarchiveObjectWithData:tileData];
        if (theTile) {
            theTile.tileOrigin = self.currentSelection;
            [tiles addObject:theTile];
            CGRect tileRect = [self rectFromOrigin:currentSelection inset:TILE_INSET];
            [self setNeedsDisplayInRect:tileRect];
        }
    }
}