OK, I was trying to convert a normal Scratch project to a standalone Mac (not iOS!) app. I tried to embed the Java applet into a html page, then display it via a UIWebView. I can't get the WebView to display the local html (applet.html in Resources), however. I have linked it up the the WebKit.framework, and can get a http file displayed with:
[webView setMainFrameURL:@"http://www.google.com"];
But
[webView setMainFrameURL:@"applet.html"];
fails.
Also, direct addresses work:
[webView setMainFrameURL:@"file:///Users/Someone/Somewhere/Something.html"];
Here are the details of my project:
iSB.xcodeproj:
[Imported WebKit.framework]
[New class: Controller.h/.m]
Controller.h:Code:
#import <Foundation/Foundation.h> @interface Controller : NSObject { IBOutlet id webView; //Linked to UIWebView IBOutlet id button; //Linked to NSButton } -(IBAction)load:(id)sender; //Triggered by the NSButton @endController.m:
Code:
#import "Controller.h" @implementation Controller -(IBAction)load:(id)sender { [webView setMainFrameURL:@"http://www.google.com"]; // Replace Google with applet.html... } @endapplet.html (in Resources directory)
Code:
<!DOCTYPE html><html><head></head><body><h1>Hello, world!</h1></body></html>
Offline
ZeroLuck wrote:
I think your WebView doesn't support Java Applets.
But you can try my Scratch to JAR Converter.
Actually, displaying the poject's website works. But I don't want or need the comments, projects notes, stats, etc.
Offline
It's normal: applet.html is only in your resources and the webkit browser displays online pages only (full addresses). Your "applet.html", in this case, is actually searched for in the same directory as the .app.
You'll have to either host the applet.html on some page or find a way to stream the hypertext into the web browser as bytes (it's possible in the .NET WebBrowser, can't remember if there's any way to do it on Macs).
Offline
I have done Objective-C in a while, but if I remember right, there is a method that takes in the name of a file in the resources and output its full path. You could try something like that.
Offline