becomeFirstResponder 在 cellForRowAtIndexPath 中不起作用 [英] becomeFirstResponder does not work in cellForRowAtIndexPath

查看:33
本文介绍了becomeFirstResponder 在 cellForRowAtIndexPath 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当从 cellForRowAtIndexPath 调用 textView becomeFirstResponder 时返回 false,为什么?

When calling textView becomeFirstResponder from cellForRowAtIndexPath returns false, why?

但是从其他方法,即从 didSelectRowAtIndexPath 它工作.

But from other method i.e. from didSelectRowAtIndexPath it works.

是否与我使用的是 iOS 8 引入了 UITableViewAutomaticDimension 行高方法有关?!

Is it in connection that I am using iOS 8 introduced UITableViewAutomaticDimension row height approach?!

推荐答案

当您查看文档时,它说视图必须位于视图层次结构中.我认为在 cellForRowAtIndexPath 方法中,文本视图尚未附加到层次结构,但在返回单元格时.

When you check the documentation it says that the view have to be in the view hierarchy. I think in the cellForRowAtIndexPath method the text view is not yet attached to the hierarchy but when the cell is returned.

你可以调用这个方法来创建一个响应者对象,比如一个视图急救人员.但是,您应该只在该视图上调用它,如果它是视图层次结构的一部分.如果视图的 window 属性包含一个UIWindow 对象,它已经安装在一个视图层次结构中;如果它返回 nil,视图与任何层次结构分离.

You may call this method to make a responder object such as a view the first responder. However, you should only call it on that view if it is part of a view hierarchy. If the view’s window property holds a UIWindow object, it has been installed in a view hierarchy; if it returns nil, the view is detached from any hierarchy.

这篇关于becomeFirstResponder 在 cellForRowAtIndexPath 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆