Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How to display html in my app? (UIKit plugin -> Feature #48) — Gideros Forum

How to display html in my app? (UIKit plugin -> Feature #48)

MellsMells Guru
edited July 2012 in General questions
Hi everyone,

- 1. HTML -

my question is : is it currently possible to display some html in my app (locally stored or online)?

Yes

-> If yes, can you give me some pointers on how to do it?

No

-> If not, is that related to Feature #48 : UIKit plugin?

What is written in the issue system :

[ Description ]
UIKit as a plugin for iOS, with webview, keyboard widget, dialog box, textedit widget, etc support. (name here all UIKit widgets).
Listed for The Next major release (due summer 2012).

@atilim What's the chance to have it available in Gideros, and how soon would it be?

- 2. VIDEOS -

Is it possible to play a video (locally stored or streamed from internet) in Gideros? (Ex : launch a video trailer from Youtube and give the users access to play/pause buttons)?

Thank you
twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps

Comments

  • ar2rsawseenar2rsawseen Maintainer
    About video, there was a plugin, which allowed you to do that, but it was for Android only
    http://www.giderosmobile.com/forum/discussion/comment/8265
  • IIRC the UIKit does support a webview so *I think* you just specify the address of the HTML file in the function that displays the control - see the UIKit example file for more info.
    WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
    #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
  • ianchiaianchia Member
    edited July 2012
    Hi @mells,

    Sure. This is easy using my tweaked uikit.mm plugin. (*iOS only*) Read this thread and follow the instructions there http://www.giderosmobile.com/forum/discussion/1206/newbie-question-about-pluginsuikit#Item_4 and grab my iOS iPad simulator installer linked there.

    Then try this:
    require "ui"; -- enable the uikit.mm plugin
     
    local video_html = [[
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" 
      content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    </head>
    <body style="margin:0; padding:0;">
    <iframe width="480" height="320" 
      src="<a href="http://www.youtube.com/embed/2LDHy5XGrWw&quot" rel="nofollow">http://www.youtube.com/embed/2LDHy5XGrWw&quot</a>;
      frameborder="0" 
      allowfullscreen>
    </iframe>
    </body></html>
    ]]
     
    local webviewA = WebView.new();
    webviewA:setTransparent(false);
    webviewA:setPosition(0,200)
    webviewA:setSize(480,320);
    webviewA:setVisible(true);	
    webviewA:loadHTMLString(video_html);
    addToRootView(webviewA);
    (IMPORTANT NOTE: the forum software has a bug and it's changed the ending quote of the YouTube URL to a & quot; ... you need to change it back to a double quote character so the string is like "http://www.youtube.com/embed/2LDHy5XGrWw" )

    To populate the web view, you can use:

    UIWebViewInstance:loadHTMLString(HTML_string);
    -- load a HTML String into the webview

    UIWebViewInstance:loadHTMLStringWithBaseURL(HTML_string, filename_of_existing_asset_as_base_URL);
    -- load a HTML string into the webview, and specify a base URL
    -- for relative path references for assets (media, javascript files etc.)

    UIWebViewInstance:loadLocalFile(local_html_filename);
    -- load a local HTML file. The .html file is used as the base URL
    -- for relative path references for assets (media, javascript files etc.)

    UIWebViewInstance:loadURL(URL_string)
    -- loads a remote URL

    and if you need to do some JavaScript injection...

    UIWebViewInstance:evalJavaScript(javascript_string);
    -- performs a JavaScript eval() statement with the javascript_string on the UIWebView instance

    I'm currently on sick leave but I'll try to upload my changes to the uikit.mm to github late next week. In the meantime, you can experiment with the Xcode iOS simulator build.

    Best,

    - Ian

  • ianchiaianchia Member
    edited July 2012
    Oh, forgot to add that if you open up Safari on your desktop, and go to http://localhost:9999 ... you can also use the desktop Safari's Web Inspector to do remote debugging of the iOS simulator's webviews. (Only supported for Xcode simulator only. Will not work on remote device due to iOS firewall.)

    More info: http://www.google.com.au/search?client=safari&rls=en&q=uiwebview+remote+debugging+localhost:9999
  • @ianchia - top post thanks.
    I'll look forward to seeing your additions to the github real soon.
    WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
    #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
  • Thank you all :)

    @ianchia
    Thank you for writing such detailed posts. That will be so helpful (to me and future searches).
    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps
  • @techdojo - just noticed that you started the http://www.giderosmobile.com/forum/discussion/1068/composing-email-and-sms-using-native-device-features#Item_1 thread.

    I've already added in-app-email functionality to my forked uikit.mm file since I was porting an existing ObjC/Three20 app to Gideros and matching existing functionality ... I'll take a look at the SMS functionality before I upload to github. It uses the same API, so it should be a no brainer. I haven't looked into the map API changes for iOS6 but I guess I'll probably add MapKit as well at some point along the way.

    - Ian
  • Wow thanks @ianchia I'll be sure to check out the github repo.
    WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
    #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
  • @ianchia - have you submitted your changes / additions to the UIKit back yet, I was particularly interested in seeing the in-app email functionality.
    WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
    #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Sign In or Register to comment.