[英]tvOS - Reset CollectionView's focus at one point of time with remembersLastFocusedIndexPath = true [swift]
I have a setup a collection view with remembersLastFocusedIndexPath
set to true.我设置了一个集合视图,将remembersLastFocusedIndexPath
设置为 true。
CollectionView is designed such a way that it has nested collection views, CollectionView 的设计方式使其具有嵌套的集合视图,
CollectionView
-> Section 1
--->Header
--->Cell nested with collectionview
-> Section 2
--->Header
--->Cell nested with collectionview
....so on....
There is pagination too.也有分页。
Now if user scrolls to say 2nd item in 7th section and clicks menu in tv remote, I am scrolling collection to top.现在,如果用户滚动到第 7 部分中的第 2 项并单击电视遥控器中的菜单,我正在将集合滚动到顶部。 [either by setting content offset to 0 or scrolling to 0th index] [通过将内容偏移设置为 0 或滚动到第 0 个索引]
Requirement : After scrolling to 0th index, if user tries to focus on first cell in 0th section, I want focus to be at 0th index.要求:滚动到第 0 个索引后,如果用户尝试关注第 0 个部分的第一个单元格,我希望焦点位于第 0 个索引处。
Issue : But now collection view remembers last focused index path and scrolls to 2nd item in 7th section.问题:但现在集合视图会记住上次聚焦的索引路径并滚动到第 7 部分中的第二项。
Expected : I do not want collection view to remember the last focused index path in this case.预期:在这种情况下,我不希望集合视图记住最后一个聚焦的索引路径。 In all other cases, it should be remembered.在所有其他情况下,应该记住它。 ie, after scrolling to top, I want do something like即,滚动到顶部后,我想做一些类似的事情
collectionView.scrollToTop()
resetFocus() //which should reset collection view's focus to initial index.
func resetFocus() {
//What should be written here to reset the focus of collection view.
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.