indexPathForPreferredFocusedView 没有被调用 [英] indexPathForPreferredFocusedView is not being Called

查看:25
本文介绍了indexPathForPreferredFocusedView 没有被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要指定哪个单元格应该获得焦点.

I need to specify which cell should receive focus.

根据 Apple 文档,如果 remembersLastFocusedIndexPath 属性为 false 或没有保存的索引路径,则应调用 indexPathForPreferredFocusedView 委托方法因为之前没有单元格被聚焦.

According to Apple Documentation the indexPathForPreferredFocusedView delegate method should be called if the remembersLastFocusedIndexPath property is false, or if there is no saved index path because no cell was previously focused.

在我的情况下,我在 UIViewController 中使用集合视图并将 remembersLastFocusedIndexPath 设置为 falseindexPathForPreferredFocusedView没有被调用.

In my case I am using a collection view in a UIViewController and setting remembersLastFocusedIndexPath to false but indexPathForPreferredFocusedView is not being called.

如何解释这种行为?

推荐答案

您应该将 remembersLastFocusedIndexPath 设置为 true.

You should set remembersLastFocusedIndexPath to true.

collectionView.remembersLastFocusedIndexPath = true

这篇关于indexPathForPreferredFocusedView 没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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