Hide Copy and Deselect UITextView options after copying all text

风格不统一 提交于 2019-12-05 19:58:22

If you are using the iOS5

UITextView adopts the UITextInput protocol, which has a selectedTextRange property. Set the property to nil:

Add the below code just above the last return NO.

self.selectedTextRange = nil;

Hope this helps

I have solved my problem. I have used below codes to solve.

- (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;
    [self resignFirstResponder];
}

Thanks to Mr.Vimal Venugopalan and Mr.Mrueg. It is working for me. It will help to some one.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!