Rendering HTML on Iphone - iphone

I'm planning ePub/HTML rendering system on Iphone. I’m not experience in programming on this platform and I would like to ask what is the better way to start in this topic on IPhone platform. I would like to render ePub which is HTML+CSS subpart but I don’t want simple web page view – I need interaction with text and some way to add adorners like underline or others to text – because of this simple html rendering control is not enough. Can anyone point me in right direction where to start looking?

ePubs are nothing but archives... where HTML/CSS javascript is embedded into it.. For those interactions to work you would need it to render it on a webview.
There are some "coding rules" with javascript css html you might need to follow to have a nice interactive experience with underlining of text and all that...
If you are looking for an own ePub reading app
You can have a look at this...
I am rendering an ePub by unzipping it and then rendering the contents in an UIwebView.
I am working on finding a more dynamic approach. But this should get you started..
https://github.com/zeroCoder1/Epub-Reader

Related

HTML 5 video within iPhone image frame

I'm somewhat hesitant to ask this question because it it is only borderline software development, but I've had zero luck finding what I need anywhere else.
I am building a landing page for an iPhone app and would like to have a video of the app in use that plays inside an image frame of an actual iPhone device (Apple does this on many of their marketing pages). I don't care about the video being played on anything pre-HTML 5, it can be as simple as an mp4.
Are there any tools out there that will easily generate this sort of functionality for me? Given how often I see this sort of thing, I'm surprised that I am having so much trouble finding something that just =gives it to me out of the box.
Alternatively, I am not opposed to coding something myself, so if that's the only option, a suitable answer to this question would be a pointer to some info on the best way to generically overlay an HTML 5 video on top of an image (the iPhone frame).
The reason you probably don't find anything is probably because it's so simple. Put a <video> tag inside a <div> tag, set background-image of the frame, add some padding so the video is centered within the frame, and voila.

Displaying Lots Of RichText : Choosing the best option

What is the best way to display lots of RichText (HTML formatted)
At the moment I'm working on an app for a forum. As you'd expect the posts on the site have lots of HTML formatting, lists, images bold text, colored text, etc...
Now there are several options I can think of (non of them ideal, please if you think of any other options post them in the comments):
Custom Cells using NSAttributedString+HTML + DTAttributedTextView for each post?
Problems: I used the NSAttributedString+HTML categories in the app elsewhere and it was less then ideal, creating an NSAttributedString seems to be quite expensive (slow) even in small amounts.
For 10+ posts each of which may be the length of an entire article would be awful + although DTAttributedTextView supports the IMG html tag (an most tags) it doesn't support remote loading of images unless you specify their width and height in the img tag. And for a forum where an IMG tag could be a smiley (10*10) or a screenshot (640*960) there's no way to predict that.
(Since writing this NSAttributedString+HTML, which is now renamed DTCoreText, has added full support for <img> tags and improved greatly!)
Custom Cells with a UIWebView in them for each post?
This one I considered for quite a while, however when reading this blog post I realised a problem that would cause, Smooth scrolling. The idea of having a native application for a site is that it is better then using a simple UIWebView to view the sites mobile theme. If the app lags and is jerky while scrolling that is worse not better (also as I need to display images hiding the webview's like he suggests wouldn't work). Also UIWebView's need to be created on the main thread or they break.
Back to the UIWebView?
Annoyingly besides doing a pathetic cheat, (like in the iFans app) where you only display text and then if they click it a UIWebView loads with all the nice images etc..., the only option left seems to be to do what I think the TapaTalk app does and have the entire thread view as a UIWebView. This isn't too bad as it will probably have quite good performance and will allow me to possibly add user controlled themes etc.. but I find the idea of using a UIWebView in a websites native app repulsive.
Does anyone have any experience creating web powered app, like maybe a facebook client, forum app, or new site app which had to display content from the site (I don't really count a twitter client as it only has to deal with text & links in small amounts per post). Or any ideas on the best way to display RichText content in an iOS app?
Any idea's would have to deal with the lot:
Multi Coloured Text.
Right, Left & Center aligned text.
Images (of variable size).
Bold text.
Text of different sizes & fonts.
Underlines text.
YouTube Videos.
HTML tables.
Just in case the actual question wasn't very clear in all of that I'll sum it up:
"What is the best way to display lots of RichText (HTML formatted) content for a forum client app"
So if I am reading this right, you want the forum posts of a given topic to be cells of a UITableView and the cells need rich formatting?
Assuming this is correct, I imagine each post will take up a lot of the screen (large cell height). In this case, having a UIWebView as a subview might not be as bad performance-wise as you might think. UITableView reuses cells so really only the visible cells need be loaded into memory.
I'm also assuming you are able to access the forum via an API, right? In which case, you should be able to pre-load data immediately prior to loading the view and the UIWebViews will only be used for formatting. You can even load a CSS file from your app bundle when you loadHTMLString into your UIWebView so you're not loading that from a server every time.
All that being said, if you did have a lot of concurrently visible cells it might be a different story and I'd maybe consider only showing plain text in the UITableView index and displaying the rich formatting only when the user taps the cell to view the single post. This might also be better from a design standpoint as having a ton of differently formatted cells on screen could potentially end up looking a bit sloppy.
Also, this may be obvious (especially since you seem to be both performance and design conscious) but please don't use UIWebView for UI controls. Any time I see a UIWebView tab bar or fake navigation bar I cringe (ack, Netflix). For formatting though, a lot times it's the only way to fly if you're loading a lot of dynamic content from a server.
NSAttributedString+HTML already supports lazy loading of images. See the Demo that shows how to do that. It's reasonably fast but you want to hold of parsing the HTML for content that is not on screen.
It mostly depends on what UI you want to achieve. NSAS+HTML is meant for situations where you control the quality of the HTML (i.e. because you generate it yourself). There it affords you with an unprecedented level of control over the view hierarchy because you can embed your own custom views to show images.
In other cases where you cannot be sure about the quality of the HTML you have to use UIWebView and work around all of it's limitations, one being that it takes enormous amounts of RAM and it slow to show the contents. Also UIWebView is not thread-safe (because WebKit is not).

Display "custom" view (various images, various text). Should I use UIWebView?

First: No, none of the content should be loaded from the web. All content parts are shipped with the main bundle.
I have n images and mass of text (including lists). Instead of building all view parts programmatically in objective-c if was thinking of using an UIWebView and build "only" the HTML dynamically.
Does anything speaks against it?
How does UIWebView work with local content?
Links and resources welcome.
Thanks
I would not recommend using the WebView for building application UIs. It introduces many elements that may cripple the user experience. Well, it basically depends on the complexity of the UI.
I created an App UI in WebView myself, using JavaScript and all that advanced CSS animations/transforms that WebKit has to offer, but in the end it was not good for the consumer. My goal was to make the app skinnable, but if something goes wrong - for example in JS - the WebView is stuck, except you spend the time into building a WebView wrapper for your app that deals with this.
That said I, i don't know how complex your UI is going to be, but I would say using IB or building the UI in code with cocoa is still more efficient.
Regards, Erik
I've thought about using web views in these situations sometimes, but then decided against it. 99% of the time, it's better to design the screen in Interface Builder. That will be as fast as or faster than creating an HTML page, and will give you all the benefits of elements functioning as expected (text input for example) and the possibility of customizing things programmatically. But of course, in many scenarios a web view might be the way to go (in fact, several standard UI elements have underlying web views).

Is there a HTML wrapper in Cocoa other then UIWebView?

I have a bunch of texts and images (taken from the content tag of a RSS feed item) that I want to display in my app. I've managed to extract them from the entire content tag with some regular expressions. But the thing is, in order for the texts to appear before all the images are loaded, I need to preload all the images, and even more, I need to reposition all the texts/images when an image is loaded, because I don't know their size at first, to position the element under them correctly.
I realized this is too much hard-work for such a simple task.
I searched for some simple HTML wrapper but I found nothing. And than I realized: hey, I can insert HTML directly into an UIWebView. But then again, I see UIWebView more like an iFrame in HTML, and by that I mean not a very flexible/fluid element. The content will be bigger than the iPhone screen height, can the UIWebView adjust to fit it's contents? I don't want the browser zoom features and all, but rather to blend in the page.
So bottom line: In order to display a bunch of texts combined with images, should I continue with my initial pain-in-the-ass method, should I use a UIWebView, or is there another simple element like the one in my dreams? :)
Thanks.
Definitely use the web view; it has hundreds of person-years of work behind it, and is realistically impossible for you to reproduce by yourself. To keep it from zooming, you can add a viewport meta tag to your HTML fragment.
...[S]hould I continue with my initial pain-in-the-ass method, should I use a UIWebView, or is there another simple element like the one in my dreams...
I'm not entirely sure what you have against UIWebView, it's a decent and fairly complex element that can support many behaviors. One of the extremely attractive properties of IB and Cocoa development is that prototyping is very quick. I think you should spend half an hour and play around with the component. Writing your own code is definitely an option, but layout engines (ie WebKit in UIWebView/Safari, or Gecko in Firefox) is a complicated task. Why reinvent the wheel?
HTH.

How can we use CSS for developing native iPhone app?

I am not developing any web app.
I am trying to use CSS in developing iPhone native app.
I am confused about where to include it and use it .
Whether to use it in the viewDidLoad or applicationDidFinishLaunching .
I am really getting tired of using the same UI look.
Can any body help me?
Thank You All.
The question you seem to be asking is "How can I make my UI skinnable" which is completely independent of any kind of technology for representing those choices.
If you want to built an HTML based application, then you can either have a UIWebView or develop a web-based application, both of which can be skinned with CSS.
If you want to make a UIKit application customisable (by changing background colours etc. and the like) then you'll have to roll your own way of doing that. CSS would be overkill for this purpose, and in any case, there is no 'standard' support for themeing applications. You might as well just write into the user defaults (probably via a settings bundle) what the user would prefer as a background colour etc. and then write a method to traverse your UIKit hierarchy to change the background colour as appropriate.
What are you trying to apply the CSS to? CSS is only going to be applicable to a UIWebView in general. For that, you'll load it in the HTML as you would for a website.
If this is still something that interests you there is a very early beta stage of CSSApply on github
Extremely lightweight skinning system for iOS. It allows you to load a
CSS file and skin UIView elements. The system also allows you to do
simple searches for subviews like jQuery with CSS selectors.