Does apple allow local HTML?

Discussion in 'iOS Development' started by Collateral, Oct 12, 2009.

  1. Collateral

    Collateral Active Member

    Joined:
    Sep 23, 2007
    Messages:
    1,974
    Likes Received:
    6
    Device:
    iPhone 3GS (Black)
    Does apple allow you to use the UIWebView to access local HMTL files in your app package? Will this have your app rejected from the appstore? I'm not sure because its allowing your application to run other code, however this code would be inside the application sandbox.


    Sorry if this has been answered but i googled it and searched here and did not find it.
  2. ipodtouchdude

    ipodtouchdude Member

    Joined:
    Apr 18, 2008
    Messages:
    279
    Likes Received:
    3
    Device:
    iPhone 5 (Black)
    apple will let you use them its just like loading a sound thats in the app so the answer is yes
  3. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    You can definitely use a UIWebView with HTML content inside your app! Many apps use a web view to display additional information or show a 'help' screen.

    Assuming your HTML file is in the app bundle, you can run this code:
    [OBJC][myWebView loadRequest: [NSURLRequest requestWithURL: [NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource: @"myWebPage" ofType: @"html"]]]];[/OBJC]
    It's sort of expensive, but you'll only have to run it once. There's also the HTML string method you can use, but I think letting the web view handle reading the file *may* be more efficient than reading the file into memory yourself.

    Hope I helped!

    Please Register or Log in to view images

  4. Collateral

    Collateral Active Member

    Joined:
    Sep 23, 2007
    Messages:
    1,974
    Likes Received:
    6
    Device:
    iPhone 3GS (Black)
    Fantastic. Thank you.
  5. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    Welcome!

Share This Page