强制查看以在Apple TV/TVS上重新加载TVL内容 [英] Force view to reload tvml content on Apple TV/tvos

查看:165
本文介绍了强制查看以在Apple TV/TVS上重新加载TVL内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力为Apple TV上的tvOS应用动态生成具有非常频繁更改内容的tvml模板.生成模板效果很好,但是当在视图之间来回导航或离开并重新进入应用程序时,我无法使应用程序更新/重新加载模板的内容.只有重启才能重新加载tvml模板.

I have been working on dynamically generating tvml-templates with very frequently changing content for a tvOS app on Apple TV. Generating the templates works fine, however I have not been able to get the app to update/reload the content of a template when navigating back and forth between views or leaving and reentering the app. Only rebooting seems to reload the tvml template.

推荐答案

每当您在模板文档中操作TVML时,模板都会自动刷新.

Your template will refresh itself automatically whenever you manipulate the TVML within the template document.

如果您像这样维护对文档的引用:

If you maintain a reference to the document like so:

var myDoc;

resourceLoader.loadResource(templateURL,
   function(resource) {
     if (resource) {
       myDoc = self.makeDocument(resource);
     });
   }                         

您可以使用 myDoc 操纵TVML,并且视图将自动更改.

you can manipulate the TVML using myDoc and your view will automatically change.

因此,如果您的模板文档包含"collectionList",并且您要运行以下代码:

So if your template document includes a "collectionList" and you were to run this code:

//Removes the child elements of the first collectionList
var collectionLists = myDoc.getElementsByTagName("collectionList");
var collectionList = collectionLists.item(0);
while (collectionList.firstChild) {
   collectionList.removeChild(collectionList.firstChild);
}

您的视图将不再显示collectionList中的UI元素.运行代码后,视图将自动刷新.

your view would no longer display the UI elements within the collectionList. The view will refresh itself the moment the code is run.

这篇关于强制查看以在Apple TV/TVS上重新加载TVL内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆