【问题标题】:UITextField missing the paste functionalityUITextField 缺少粘贴功能
【发布时间】:2012-10-09 21:12:13
【问题描述】:

如果需要,我可以提供代码,但是我的问题看起来很根本。我在一个可以复制和粘贴的视图中有一个 UITextField 。行动后,我不能再做一次。它只工作一次。

这背后的原因可能是什么?是否有可能因为窗口中的另一个视图而没有显示粘贴菜单?

一些代码:

    myTextField = [[UITextField alloc] initWithFrame:CGRectMake(0,1,320,50)];
    [myTextField setFont:[UIFont boldSystemFontOfSize:40]];
    [myTextField setTextColor:[UIColor whiteColor]];
    [myTextField setText:@""];
    [myTextField setBorderStyle:UITextBorderStyleNone];
    [myTextField setEnabled:YES];
     [myTextField setKeyboardType:UIKeyboardTypePhonePad];
    [myTextField setDelegate:self];
    myTextField.inputView = hiddenView; 

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

是否需要在与 UITextField 相关的 viewWillAppear 方法中添加一些内容?正如我所说的第一次效果很好。

更新:第一次粘贴后,复制/粘贴/选择机制在我的应用程序的所有视图中停止工作...

【问题讨论】:

  • 您是否尝试过在文本字段上按住手指一段时间。并确保您的文本字段是第一响应者。
  • 我没有关于 firstResponder 的代码

标签: iphone ios uitextfield uitextfielddelegate


【解决方案1】:
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender 
{
    if (sel_isEqual(action, @selector(paste:)))
    {
       return YES;
    }
    return [super canPerformAction:action withSender:sender];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-07
    • 2021-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多