UITextView全选

时间:2013-10-04 18:50:47

标签: objective-c uitextview

我正在使用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;
}

enter image description here

enter image description here

0 个答案:

没有答案