iOS WebView extension beta
This is a beta release of my WebView extension which allows you to embed online content into your app via iOS's built-in UIWebView component.
http://dl.dropbox.com/u/3847822/MMF/WebView_beta.zip
Please see the WebView.htm help file for details and the Browser.mfa file for an example.
Please post any issues you have on this thread. I've only tested it on the simulators and my own iPhone 3GS so far.
Here's the main description from the help file:
"This WebView object allows you to embed online content into your MMF iOS app. You can set its placement and dimensions as you wish in the frame editor, send events to make it load urls, and query it about its loading status (to display "loading..." messages and such). The user can zoom in out and out with gestures, fill out online forms, click links, etc in WebView just like on Safari. Any media files that QuickTime can normally play in Safari will play in WebView as well (with that same 'going to fullscreen' behavior that QuickTime does in Safari). Some HTML5 works correctly in WebView, some not (you'll just have to test).
Caveats: iOS UIWebView, which is what this extension invokes, is a little slow and limited compared to iOS Safari, so for just sending someone to your site, for example, you're better off using the MMF iOS Object's "Open URL" action, even though it takes the user out of your app (the user will be able to bookmark your site in Safari, for instance). Likewise, a https:// connection requiring login or other authentication is better handled through iOS's Safari browser. Some JavaScript does not work in UIWebView. UIWebView does not offer identification that all sites understand, so a site may serve up limited content. So it's not a great idea to use WebView for general web-browsing. *But* if there's some specific web content you want to display in your app, it may be of good use to you.
On the PC side within MMF, the extension is basically just a shell to allow you to place and size the WebView window in your frame, and to attach events to it. It has no functionality when run on a PC. You can see it in action once you've built your app's XCode project and are running it in a simulator or iOS device.
A Browser.mfa showing a basic web browser is included as an example of WebView's functionality, not as an example of a good browser. ;)."
Re: iOS WebView extension beta
Thanks, I will test it out :)
Re: iOS WebView extension beta
Nice! Will have to check it out.
Re: iOS WebView extension beta
Great work! I haven't tested yet, but I imagine this will be a great help to many devs.
Re: iOS WebView extension beta
I got an exciting idea for what this could be used for... :D
Re: iOS WebView extension beta
Thanks, all! Anyone have a chance to try it out yet? Any issues?
Re: iOS WebView extension beta
Hey, I haven't had a chance to play around with this yet. But is there a way that it can just load read-only page? As in the user cannot scroll around in it or zoom?
I want to put maybe like a small news feed on the title screen. Also, does this test for an internet connection? Let's say someone is using an iPod Touch with no current internet access, can I change what it says in the webview extension?
Re: iOS WebView extension beta
I think I can add some actions to enable/disable zoom (would toggle the UIWebView's scalesPageToFit property) - I can test that soonish. I don't think there's a way to disable scrolling, but I think if the content "fits" the view completely, there should no scrolling - so you can try to style the content and shape the webview to achieve that.
As for a message if there's no internet connection, yes, there is a "Did WebView fail to load a url?" condition you can use to respond in whatever way you wish to the webView not being able to load the requested url.
Except, you can't explicitly set WebView to display a string, it'd have to be some external string or graphic object, etc outside of the WebView (this is shown in the browser example) that indicates the loss of connection to the user. But...UIWebView is apparently able to load documents from the appbundle as well, so theoretically you could make a custom "Sorry, no internet" html page, and then load it into the WebView for that condition, but I haven't played around with document loading at all yet.
Re: iOS WebView extension beta
I'm actually working on a kind of educational quiz app that links you to a relevant wikipedia page after an answer. This extension is *ideal* for what I need for this project.
One thing though, I've got it working and everything, but I can't seem to zoom and in the default view it gives me, the text is too small to read. Being able to have a default zoom value if that's possible would be great for what I need too.
If you could develop this to where I can use it for this project, I'd be happy to send some money your way :)
Re: iOS WebView extension beta
colej_uk, yes I've noticed some sites (especially the mobile version of some sites) disable zoom somehow. I've been reading about a workaround for that which I'll attempt to add to the extension soon.
Re: iOS WebView extension beta
I actually opened a wikipedia page in safari today, and noticed that it wouldn't let me zoom either, but the text size was much bigger- allowing it to be read easily.
This was actually preferable to zooming in because you don't have to keep manually scrolling left/right when in portrait mode to read properly if that makes sense. Would this be easy to implement?
Re: iOS WebView extension beta
Yes, UIWebView doesn't provide any direct ways to control its zoom and font size programmatically *but* it does have a method for executing strings of javascript. So if I get an MMF Action for that method working, you'd be able to feed it strings like:
"document.body.style.zoom = 5.0;"
and
"document.getElementsByTagName('body'[0].style.webkitTextSizeAdjust= '60%'"
to set the zoom and text size as you'd like.
I'll be looking into that next. :)
Re: iOS WebView extension beta
Re: iOS WebView extension beta
Does this not work in landscape mode?
I've copied all the events, objects, etc from the example file, copied into a new frame on my game, and it just seems like the webview extension is not showing up at all. The buttons won't do anything.
Please help,
thank you
Brian
Re: iOS WebView extension beta
xhedgehogx, for me it's working in landscape mode in the iphone & ipad simulators, and on my iphone3gs (though I do notice the iOS keyboard still comes in portrait mode, I think that's something CT will have to adjust in the SDK).
http://dl.dropbox.com/u/3847822/MMF/..._landscape.jpg
Make a backup of your xcode project, and then replace your Application.cci with this one, and see if it works.
Here's the landscape mfw file, too.
Re: iOS WebView extension beta
Re: iOS WebView extension beta
jjsonick:
I recently fixed a generic bug with the device orientation and UI controls (like popup alerts and possibly also keyboard orientation).
It is currently being beta tested.
Re: iOS WebView extension beta
Andos: awesome! Thanks. I did see the issue with popup alerts generated by the WebView too, so hopefully it will fix both.
Re: iOS WebView extension beta
Thanks to you jjsonick, i made my application "programme tv gratuit" with webview !
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=249078#Post2490 78
Re: iOS WebView extension beta
wesleyd, that's awesome! Congrats! :D
Re: iOS WebView extension beta
This looks cool! I'll try this out.
Thanks for this :D
Re: iOS WebView extension beta
I just tried this out and it works, so that was good.
Is there any way to run an index.html file locally using this extension?
Re: iOS WebView extension beta
Not yet, but iOS webview has the ability to load local documents - adding that hook to the extension is on a to-do list.
Re: iOS WebView extension beta
Would be rather interesting if you supported a named directory for local content such as "www" and if someone specified a resource without a schema (HTTP/HTTPS) you would try to load it from this www folder.
This link shows a good example of loading from local resources:
http://stackoverflow.com/questions/2517918/iphone-dev-load-a-file-from-resource-folder
Great work on the extension BTW.