我的控制器上有一个UITableView。当控制器显示页面时,它是焦点。tvOS UITableView在Apple TV上导致错误,但不是模拟器
当焦点行更改时,我想更新下面代码中的UITextView(称为_appText)。
这一切都在模拟器中工作正常,但是当我在苹果电视我收到以下错误上运行:
终止应用程序由于未捕获的异常“NSInternalInconsistencyException”,理由是:“_ignoreFocusUpdateIfNeeded的不应该是重点更新开始。“
我的苹果电视
这里运行tvOS版本9.01的代码:
- (void)tableView:(UITableView *)tableView didUpdateFocusInContext(UITableViewFocusUpdateContext *)contextwithAnimationCoordinator:(UIFocusAnimationCoordinator*)coordinator{
NSInteger ourRow=context.nextFocusedIndexPath.row;
NSString *path =[[NSBundle mainBundle] pathForResource:[_appIconNames objectAtIndex:ourRow] ofType:@"html"];
NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];
NSAttributedString *thisString=[[NSAttributedString alloc] initWithData:[content dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)}documentAttributes:nil error:nil];
_appText.attributedText=thisString;
}
这会导致错误的代码行是:
NSAttributedString *thisString=[[NSAttributedString alloc] initWithData:[content dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)}documentAttributes:nil error:nil];
想不通为什么它在模拟器中工作,而不是苹果电视本身。
您使用的是电脑键盘使用模拟器进行导航?我和你在不同的项目上有同样的错误,但只有当我在模拟器上使用“Apple TV Remote”进行导航时。我不知道如何解决这个问题,但也许事件与此有关。 –
另外,我有这个问题,因为我使用NSAttributedString来显示一个NSHTMLTextDocumentType文档以及..它可能是一个与焦点和UITextView或NSAttributedString相关的错误 –
我也遇到了这个..任何更新它?我不确定发生了什么,但只有当我尝试将HTML放入像您这样的属性字符串时才会发生。 –