如何在UITextView iPhone应用程序中控制复制,粘贴,全选,定义? [英] How control Copy, Paste, Select All, Define in UITextView iPhone app?

查看:247
本文介绍了如何在UITextView iPhone应用程序中控制复制,粘贴,全选,定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UITextView在iPhone应用程序中工作。我想允许用户只能复制邮件并粘贴邮件。但我不想显示全选,选择,定义和其他。我按照以下代码来控制选项。但是,所有选项都显示在UITextView单击中。

I am working in the iPhone app using UITextView. I want to allow the user only can Copy the message and Paste the message. But i don't want to show Select all, Select, Define and others. I am following this below code to control the options. But, all the options are showing in UITextView click.

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    if (action == @selector(paste:))
    {
        return NO;
    }
    else if (action == @selector(copy:))
    {
        return NO;
    }

    return [super canPerformAction:action withSender:sender];
}

任何人都可以帮我这样做。而且我也不想在复制邮件时显示 | .Text。| 。请帮我这样做。在此先感谢。

Can anyone please help me to do this. And also i don't want to show |.Text.| while copying the message. Please help me to do this. Thanks in advance.

推荐答案

首先,如果您上面的代码不起作用,那么您可能忘了更改课程您的UITextView实现上述方法的自定义类。

First of all if the code you have above isn't working then you probably forgot to change the class of you UITextView to your custom class that implements the method above.

一旦你完成了你所得到的应该工作,然后你应该返回no for select all还

Once you've done that what you've got should work and you should then return no for select all also

   if (action == @selector(selectAll:))
        {
            return NO;
        }

你也可以为切割返回no:还假设你没有希望用户从textView中删除文本。

also you may want to return no for cut: also assuming you don't want the user to remove text from the textView.

此外,这些不需要if else语句,因为它们不相互依赖

Also these don't need to be if else statements as they don't depend on each other

他们实际上按此顺序调用

They are actually called in this order

cut:
copy:
select:
selectAll:
paste:
delete:

cut: copy: select: selectAll: paste: delete:

因此,请删除相应的功能。

So remove functionality as appropriate.

这篇关于如何在UITextView iPhone应用程序中控制复制,粘贴,全选,定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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