How to create books for Kindle Fire that allows for panning and zooming similar to Newsstand? - epub

To be clear, this is a programming question. I want to publish a book for the Kindle Fire that has images that can be pinched, panned and zoomed in the same manner as the content for the Newsstand does. I have researched this a lot, and can't find any information on how to do this, but there is a lot of information on how to do other things.
There are fixed layout samples that show how to do "comic-style" image overlays, that do not allow for panning and zooming.
There are samples that show using the <img> tag, which allows you to double tap into an image viewing mode of sorts, that allows pinching, panning, and zooming, but you have to tap an "X" to get out of that image mode to continue reading.
However, for magazine content, ie. the stuff that you buy from the "Newsstand" (almost all, and I can provide a video sample if need be), are navigable the way I would like my book to be. You can view a whole page, pinch to zoom in, pinch to zoom out, pan, and swipe to go to the next page.
It is likely that this is impossible for "books," and it is only possible if you have a magazaine publishing contract with Amazon, (and it uses a different format), but I am having a difficult time ascertaining that for sure from any source. I've searched and asked on the fora there with no luck.

As you noted, the magazines are a different format... and that's the difference. KF8 is HTML and doesn't let you pinch & zoom.

Related

Draw above UIWebView in Swift

I'm looking for a way to draw "Lines" above a UIWebView.
I have a UIWebView that display a PDF file, the user should be able to add "Lines" and "Sketches" (simple one color lines etc) for sure this could be done with a UIView on top of the UIWebView but i m running into 2 logical problems.
First can the UIView where the drawing is, be transparent beside the lines - so you can view the pdf through it?
How could i handle the zooming in the PDF, if a user zoom the WebView, the UIView have to zoom "with each other" - so the drawing stays at the same spot/zoom level?
Is there any other way to display a PDF and add drawings/annotations to it? Currently i m using a QLPreviewController where i see no way to add any kind of annotations?
Is three any best practice for this?
PSPDFKit handles this (and many other hard PDF problems) very well. Using a web view for this kind of problem is likely to have many little corner cases. Any commercial product that has non-trivial needs around PDFs should definitely start there. For open source projects I don't have a great answer beyond "yeah, PDFs are a pretty tough; good luck."
That said, here are some starting points that may help you.
You can turn off zooming with webView.scalesPageToFit = false
You can get the current zoom scale using webView.scrollView.zoomScale
I believe you can KVO observe zoomScale to track it while it changes, but you may only get the target value (which will cause you to lag).
You can disable zooming (scalesPageToFit) and then re-implement it yourself with a UIPinchGestureRecognizer and scrollView.setZoomScale(_:animated:). That way you could track the zoom changes better. You could also try to handle the animation yourself with a CABasicAnimation so that you could keep it in sync.
My experience with scroll views, web views, and PDF is that there are a lot of little funny interactions that will surprise you. Getting something that "kind of" works isn't that hard, but getting it really clean, smooth, and beautiful can be a nightmare. That's why I typically recommend PSPDFKit to clients. You'll generally spend much less on the license than on the custom development.

view images in ios7 app and make interactive

ok guys im not to shure where to start with this one its a first for me but i have a floor plan that i would like to show in my IOS7 App and i know i want the user to shrink and grow the image so he or she can zoom in to areas of the map. it would be nice if they could click on the an area of the image and it would be linked to data in my parse database. but i think thats a long way off for me.....
but for now just to let the user shrink and grow and rotate the image would be nice.
anyone got any tutorials they can point me to?
Have a look at Apple's PhotoScroller example. Here an ARC-ready version.
This will not cover rotating the image, but you can easily get this by following this tutorial.

jQuery-based image carousel or horizontal scroller control for iPad swipe event?

I am writing a web-based application for Safari on the iPad and am looking for a jQuery-based solution for horizontal navigation. I've found several examples, but I want to create/use a horizontal carousel containing images hopefully stored in a <ul>. The selected image would be enlarged and in the middle of the carousel while the other images before and after the selected image would still be visible but smaller. A person could then swipe in either direction (no mouse click) to scroll left/right (or up/down through the <ul>).
I explored jQueryMobile and jQTouch and found many examples of using swipe but would like to avoid having to create this from scratch to address my requirements described above, if possible.
I've also found several good jQuery slider plugins like Swipe and Flexslider but I guess I'm being picky as I want to be able to preview the next images, as well as use something like the momentum property to scroll faster if a quick swipe.
I also found a similar topic posted on Stack Overflow.
Any help, pointers or advice is appreciated.

Is there a way to implement native ipad/iphone 'flipping' through an album of pictures through a website?

I think I've seen some implementations in flash, although I'm not sure.
On my ipad, through the photos app, you can open an album and scan through FULLSCREEN images using the flick to move it from side to side. My question is: can this be implemented through a website flipping through a album (collection of images)?
Thank you!
Here's something that might help:
http://jsfiddle.net/sje397/PzQgs/
It doesn't handle the mouse gestures, but shows one way to 'flip' full screen images.
To handle the 'flick' mouse gesture, you'd need to track mouse position and button states with event handlers & timers.
The "flipping" mechanism you're describing is called "cover flow" And there's a few implementations on the internets. The one I've heard recommended the most is http://xflow.pwhitrow.com/

iPhone OS 3.2; PDF rendering; User Interaction

I'd need to create a iPad-app which would be rendering multiple PDF-Files (one file contains one page).
Each page should be scrollable, zoomable and if the user taps on a part of the PDF a website or photo gallery should popup.
Currently i think i could do that either with:
A. UIWebView
Displays the pdf's nicely, scrolling and zooming works. But it looks like a lot of trouble to realize the clickable parts of the PDF.
I don't know if i could use CGPDFContextSetURLForRect
Getting the touch-events from UIWebView to do something like CGPDFContextSetURLForRect my self looks like it would be some "quite bad" hack. See: http://github.com/psychs/iphone-samples/blob/master/WebViewTappingHack/Classes/PSWebView.m
B. Quartz
I found some resources describing how to display PDF's directly via Quartz.
See:http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf/dq_pdf.html
This would allow using CGPDFContextSetURLForRect
But i have no idea if this would - like UIWebView - support scrolling and zooming out of the box?
Anybody could enlighten me on this please?
Thanks for your time!
[Edit: changed 3.0 to 3.2]
[Edit: my "solution"]
Hi!
I could come up with a working implementation for PNG but not for PDF's.
[Abstract]
My sollution was Rendering the content, intercepting the touches on it, retreiving the coordinates relative to the displayed content if it is one touch and finally looking up what to do from a mapping containing the interactive areas as coordinates and what to do if they get clicked.
[For PNG]
It was way more cumbersome to implement somethink like that than i would have imagined...
And the implementation i got working depends heavily on the content you want to display because this does work for UIImageView but i could not get it working with UIWebView.
First you need a UIScrollView and UIImageView to render the content and support scrolling/zooming.
Then you need to implement some handling to get the touches/gestures you are interested in.
See: developer.apple.com/iphone/library/samplecode/ScrollViewSuite/Listings/1_TapToZoom_Classes_TapDetectingImageView_h.html
This sample from apple provides everything you need to get this part working.
As a bonus it also takes care about transforming the coordinates relative to the viewport of the content which is very handy! (else you would only know where the tap happend on the screen wich only one half of the info you need if your content is zoom-/scrollable)
[For PDF]
If you want to do this with PDF the first thing would be that you need to use a UIWebView (probably you could do it via Quartz or something else too)
Getting the touches with a UIWebView is a real pain!
There are a lot of ways proposed on the web and besides one noone did what it should do.
After days of googling i found this gem: cocoawithlove.com/2009/05/intercepting-status-bar-touches-on.html
So... subclassing UIWebView does not get you anywhere unlike UIImageView and you have to subclass UIApplicationMain and implement its method for handling touch-events.
Here you could reuse some of the "Touch-Handling-Stuff" from the apple-examlpe from above.
Now you would need to translate the coordinates of the touch to your content if it is zoom-/scrollable. UIWebView DOES NOT do this for you unlike UIImageView!
I could never figure out how to get the required information(what part of the content at which zoomlevel) from a UIWebView to translate the coordinates but due to the changed requirements from PDF to PNG i didn't care to get it working too much.
hope this helps.
Using the CGPDF* operators will allow you to write a UIPDFView, which operates exactly as UIImageView but uses a PDF as the source image. Create your own custom subclass of UIView and implement drawRect: to, eventually, call CGContextDrawPDFPage. Based on a quick Google search (because I know the keywords), this page seems to explain that side of things quite well.
You can then directly substitute your custom UIView subclass for the UIImageView and proceed exactly as you have with the PNG solution.

Resources