2
在tvOS中,有一个集合视图。每个“行”是一个图像。每个图像都有与之相关的文字。当用户将鼠标悬停在图像上时,文字会更改为与图像匹配。但是,我希望用户能够访问文本,而不必将焦点放在选择的图像和UITextView之间的图像之间。如何使UITextView成为tvOS的焦点?
使用播放/暂停按钮,我可以切换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];
}
}
}
}
让我改说一下。我需要做的是:使用播放/暂停按钮使UITextView聚焦,并在IB中选中具有“调整聚焦图像”的行时“散焦”,从而不调整图像。然后当再次点击播放/暂停按钮时发生相反的情况。 – user3160965