2015-10-19 45 views
0

剛開始玩tvOS,我無法讓焦點引擎在我的收藏視圖上工作。焦點與幾乎所有其他UI元素(如按鈕和表視圖)一起使用,但不適用於集合視圖。焦點引擎不在集合視圖單元上工作

我試着覆蓋代表canFocusItemAtIndexPath並將單元格設置爲cell.camBecomeFocused(),但它們都沒有工作。

謝謝你們

回答

1

你應該看看preferredFocusedView方法。

https://developer.apple.com/library/prerelease/tvos/documentation/UIKit/Reference/UIFocusEnvironment_Protocol/index.html#//apple_ref/occ/intfp/UIFocusEnvironment/preferredFocusedView

您可以以指定哪些子視圖應該獲得焦點,當小區集中添加到您的收藏查看單元格。例如:

- (UIView *)preferredFocusedView 
{ 
    // In this case, there would be a UITextField hooked up as _myTextField_ 
    return self.myTextField; 
} 

現在,當集合視圖小區集中,在這個例子中,文本字段會獲得焦點。

0

我有同樣的問題,我無法重新加載時重點UICollectionView。這個解決方案解決了礦難問 正如蘋果工程師所說,默認情況下UICollectionViewCells沒有任何焦點,但是您的imageView可以設置爲adjustsImageWhenAncestorFocused爲YES,這表示focusViewCell中的焦點。

這是代碼。

cell.imageView.adjustsImageWhenAncestorFocused = true 

另請參閱此鏈接。 https://forums.developer.apple.com/message/56262#56262