1

我正在使用 UITextView,如何在编辑菜单中显示全选?那么当用户单击全选时,编辑菜单将只显示复制和定义?

此代码不起作用:

    - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    if (action == @selector(copy:) || action == @selector(select:) || action == @selector(selectAll:))
    {
        return [super canPerformAction:action withSender:sender];
    }

    self.TextArea.selectedTextRange = nil;

    return NO;

}

-(void)select:(id)sender
{

}

-(void)selectAll:(id)sender
{
    [self.TextArea setSelectedTextRange:[self.TextArea textRangeFromPosition:self.TextArea.beginningOfDocument toPosition:self.TextArea.endOfDocument]];

}

-(void)copy:(id)sender
{
    self.TextArea.selectedTextRange = nil;
}

在此处输入图像描述

在此处输入图像描述

4

0 回答 0