在tvOS中,有一个集合视图.每个"行"是一个图像.每个图像都有与之关联的文本.当用户"悬停"在图像上时,文本将更改为与图像匹配.但是,我希望用户能够转到文本而不将焦点放在所选图像和UITextView之间的图像之间.
使用播放/暂停按钮,我可以切换UITextView的背景颜色,但UITextView无法获得焦点.用户必须使用遥控器来选择UTTextView.
这是代码:
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIEvent *)event {
for (UIPress *item in presses)
{
if(item.type == UIPressTypePlayPause) {
//should reactivate uicollectionview
if (_isPlay) {
_isPlay = NO;
_artistsCollectionView.userInteractionEnabled = YES;
_textViewForBiosAndHelp.backgroundColor = [UIColor lightGrayColor];
[_textViewForBiosAndHelp resignFirstResponder];
[_artistsCollectionView becomeFirstResponder];
[_artistsCollectionView preferredFocusedView];
//the purpsoe is to go to the textview. it does not.
}else{
_isPlay = YES;
_artistsCollectionView.userInteractionEnabled = NO;
_textViewForBiosAndHelp.backgroundColor = _aColor;
[_artistsCollectionView resignFirstResponder];
[_textViewForBiosAndHelp becomeFirstResponder];
[ _textViewForBiosAndHelp preferredFocusedView];
}
}
}
}
Run Code Online (Sandbox Code Playgroud)