Web app in tvOS
EDIT: 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
If you want to use an UIWebView (as proof of concept) you can do this:
Objective-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];
swift
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)
MAGIC!!! The UIWebView
is there! But you can't iteract with it, just show web pages or web content.
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
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.
Fetch Web HTML data in tvOS
Just make the HTTP request directly using NSURLSession
. You'll get the HTML back as NSData
and can parse it from there just like before. You should probably do the same in your iOS app: if you're not going to show the HTML to the user then there's no point in using something as heavyweight as a web view.
Can you develop web apps for Apple TV?
There is no web browser on the Apple TV, so you can't currently develop web applications for a non-jailbroken device. Same goes for native applications.
Jailbroken Apple TVs are another story, but it sounds like that isn't your target here.
Related Topics
Fix First Column of a Bootstrap Table
Jquery Add Class Based on Page Url
How to Access Styles from React
How to Get Color Value from Gradient by Percentage with JavaScript
Convert JavaScript-Generated Svg to a File
How to Zoom a Background Image on a Div with Background-Size
Affix Is Not Working in Bootstrap 4 (Alpha)
Iis 7.5 No Images CSS Js Showing
Calculate Color Values from Green to Red
Jquery/JavaScript Opacity Animation with Scroll
How to Toggle Class Using Pure JavaScript in HTML
How to Inject a Style with an "!Important" Rule
Clean Way to Programmatically Use CSS Transitions from Js
Most Elegant Way to Force a Textarea Element to Line-Wrap, *Regardless* of Whitespace
How to Make My Navbar Change CSS Class Upon Scrolling Past an Anchor Point
Center an Image Vertically and Horizontally Using CSS
Getelementsbyclassname to Change the Style of Elements When Event Occurs