如何使UITextView文本全部可选并显示复制到用户iPhone应用程序的选项? [英] How to make UITextView text all selectable and show copy option to the user iPhone app?

查看:47
本文介绍了如何使UITextView文本全部可选并显示复制到用户iPhone应用程序的选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iPhone应用程序(如iMessage本机应用程序)中工作.我设计了一个页面,类似于iMessage,还添加了气泡.我是怎么做的,只需添加UITextView in UITableView Cell and also i have added UIImageView on UITextView with bubble images.

Am working in iPhone application like iMessage native app. I have designed a page look like iMessage with added a bubbles also. How i done is, just added a UITextView in UITableView Cell and also i have added UIImageView on UITextView with bubble images.

将文本从NSMutableArray加载到UITextView.一切正常.现在我的疑问是:

Load the text to UITextView from NSMutableArray. It is working fine. Now my doubt is:

  1. 在iMessage应用中,他们将其设置为when the user hold the bubble they making the text as selectable and showing Copy option.在我的应用程序when the user hold a bubble the Copy option showing but some particular text only copying中.我如何选择所有文本并向用户显示复制选项?

  1. In iMessage app they set that when the user hold the bubble they making the text as selectable and showing Copy option. In my app when the user hold a bubble the Copy option showing but some particular text only copying. How can i select all text and show copy option the user?

在iMessage应用程序中,未显示选择区域(选择开始和选择结束两行).但是在我的应用程序中,selection regions are showing how can i manage that?

In iMessage app the selecting region (two lines in beginning of selection and end of selection) not showing. But in my app the selection regions are showing how can i manage that?

能否请您帮我解决这个问题?预先感谢.

Could you please help me to solve this issues? Thanks in advance.

推荐答案

最后,我已经解决了以下代码所使用的问题.现在可以从UITextView中选择所有内容,并向用户显示复制"选项以复制消息.请找到代码以供参考.

Finally i have solved my problem used below code. Now am able to select all content from UITextView and showing Copy option to the user to copy the message. Please find the code for your reference.

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    if (action == @selector(copy:))
    {
        [self selectAll:self];

        return YES;
    }
    else if (action == @selector(cut:))
    {
        return NO;
    } 
        return NO;
}


- (void)copy:(id)sender 
{
    UIPasteboard *pastBoard = [UIPasteboard generalPasteboard];
    [pastBoard setString:self.text];
    self.selectedTextRange = nil;
}

快乐编码.

这篇关于如何使UITextView文本全部可选并显示复制到用户iPhone应用程序的选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆