【发布时间】:2015-11-07 05:27:18
【问题描述】:
在 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];
}
}
}
}
【问题讨论】:
标签: objective-c tvos apple-tv