本文介绍了iOS-是否可以强迫UILabel子类对象成为第一响应者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法吗?

我尝试将以下内容放入子类:

I tried putting the following into the subclass:

- (BOOL)canBecomeFirstResponder 
{
    return YES;
}

但是,当我向对象发送"beginFirstResponder"消息时,它仍然没有成为第一响应者.

But when I sent the object a becomeFirstResponder message, it still didn't become the first responder.

推荐答案

是的,有可能.您应该:

Yes, it is possible. You should:

  1. 覆盖 becomeFirstResponder 以返回 YES .

userInteractionEnabled 设置为 YES .

添加 UITapGestureRecognizer 来处理点击.

从点击处理程序中调用 becomeFirstResponder .

Call becomeFirstResponder from the tap handler.

您甚至可以覆盖 inputView ,以在屏幕底部获取输入控件.否则将一无所有.

You can even override inputView to get a input control at the bottom of the screen. Otherwise there will be nothing.

这篇关于iOS-是否可以强迫UILabel子类对象成为第一响应者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 14:59