tvOS 中的网络应用 [英] Web app in tvOS

查看:23
本文介绍了tvOS 中的网络应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple 昨天发布了 Apple tv SDK.

Apple has released it's SDK for apple tv yesterday.

大多数电视应用程序都是基于网络的(html、javascript 和 css),我想将现有的电视网络应用程序移植到 tvOS.

Most apps for TVs are web based (html, javascript and css) and I would like to port an existing tv web app to the tvOS.

Xcode 中的 SDK 没有像 iOS 中那样显示用于创建基于 html、javascript 和 css 的应用程序的 Webview 实现,但是,根据文档,可以通过 tvjs 框架,但不是 html,苹果有自己的电视标记语言 TVML.

The SDK in Xcode shows no Webview implementation like in iOS for creating apps based in html, javascript and css, however, according to the docs, it is possible to use javascript using tvjs framework, but instead of html, apple has it's own markup language for TVs called TVML.

我的问题是:是否可以将现有的 Web 应用程序移植到 tvOS(如何?),还是需要从头开始重新实现?

My question is: Is it possible to port an existing web app to tvOS (how?), or does it need to be reimplemented from scratch?

感谢您的帮助.

推荐答案

在人们继续投票之前,我要明确说明 UIWebView 存在于 Apple TV 上,但它禁止 使用它,因此,在 Apple TV 上加载网络应用程序的唯一真正方法是使用 TVML 和 TVJS 创建它们

Before people keeps downvoting, I'm going to make clear that the UIWebView is present on the apple TV, but it's PROHIBITED to use it, so, the only real way of loading web apps on an apple TV is creating them with TVML and TVJS

如果您想使用 UIWebView(作为概念证明),您可以这样做:

If you want to use an UIWebView (as proof of concept) you can do this:

目标-c

Class webviewClass = NSClassFromString(@"UIWebView");
id webview = [[webviewClass alloc] initWithFrame:self.view.frame];
NSURL * url = [NSURL URLWithString:@"https://www.google.com"];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];
[self.view addSubview:webview];

迅速

let webViewClass : AnyObject.Type = NSClassFromString("UIWebView")!
let webViewObject : NSObject.Type = webViewClass as! NSObject.Type
let webview: AnyObject = webViewObject.init()
let url = NSURL(string: "https://www.google.com")
let request = NSURLRequest(URL: url!)
webview.loadRequest(request)
let uiview = webview as! UIView
uiview.frame = CGRectMake(0, 0, view.frame.width, view.frame.height)
view.addSubview(uiview)

魔法!!!UIWebView 就在那里!但是你不能用它进行迭代,只能显示网页或网页内容.

MAGIC!!! The UIWebView is there! But you can't iteract with it, just show web pages or web content.

更新!我发现github上有很多基于https://的tvOS浏览器github.com/steventroughtonsmith/tvOSBrowser,但其中大多数需要在 Xcode 应用程序上调整 Availability.h.我找到了一个使用我的方法的叉子,所以它不需要调整 Availability.h https://github.com/FabioSpacagna/tvOSBrowser它们添加了对导航的基本支持,例如滚动和光标

UPDATE! I've found that there is a lot of tvOS browsers on github based on https://github.com/steventroughtonsmith/tvOSBrowser, but most of them require tweaking Availability.h on Xcode app. I've found a fork that uses my approach, so it doesn't require tweaking Availability.h https://github.com/FabioSpacagna/tvOSBrowser They add basic support for navigating, like scroll and a cursor

我不认为苹果会批准使用 UIWebView 的应用,因为它被标记为禁止,你必须学习 TVMLTVJS相反.

I don't think apple will approve apps using UIWebView as it's marked as prohibited, you'll have to learn TVML and TVJS instead.

这篇关于tvOS 中的网络应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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