How to create an iPad document preview interface, as with iWorks for iPad

Wanting to award a +500 bounty for a working example.

There are only 2 source code examples that I know to execute the document preview interface on the iPad, such as those found in Number, Pages, etc.

infoNgen and OmniGroup Framework

Is there any other example? infoNgen is a good simple example, however, the code is extremely messy and badly written, very disorganized.

OmniGroup is a terrific library, but too complicated for simple projects.

alt text

Update

I managed to break through the infoNgen project and make a barebone-based document viewer with HTML preview, which seems to work quite well, updating the information in the document and keeping it synchronized with the preview. Only problem now is to save documents when the application exits and restarts. The +500 bounty is still available for a working example, however I am not going to open the award if working examples are not published.

+7
source share
1 answer

Shell View is the main view controller that will show your entire carousel.

The carousel itself is a UIScrollView. Just create a scroll view and set the pagingEnabled property to YES . Fit it to the appropriate dimensions using the frame settings, and then add them to your shell view controller. You will also want to set the contentSize property of the carousel view large enough. Calculate this by multiplying the number of documents, as well as the width of two more documents across the width of the carousel. If you want documents on both sides to be displayed a little, then multiply the number of documents by the scroll width, minus a few pixels.

EDIT

Actually, the problem with the search in this article led me a little to this post , which describes an alternative method for its implementation. Essentially, you end the scroll view inside the user-defined subclass of UIView, which forwards relate to UIScrollView. This is necessary because UIScrollView can only "page" for pages that have the same wide area. Using my β€œadjust the side view by a few pixels” method, you get a good preview, but the offsets will make the preview jump while scrolling. (I tried my method when you dumped the sample code. As I just explained, this did not work.) I will try another method before using the custom shell. (I wonder if content inserts work.)

Edit end

Please note that, as Matthew correctly pointed out in the comments, you actually create only 3 views that you need, as described below.

Your document previews can be any objects that you like. As you already mentioned, UIWebView can be used to render HTML. Regardless of what you want to use to present your sketches, the trick is going to be laid out.

I assume that you have an array of objects, although you can use Core Data to store your information. To show previews of documents, add them to the scroll list, but in the right place along the "X" coordinate. To calculate this value, multiply the index of the current document by the scroll width. Apply this value using the setFrame method of the document preview. You will also want to preview before and after, so that you have smooth animation.

To handle rendering and scrolling, you'll want to make your wrapper in a UIScrollViewDelegate. The delegate should tell UIScrollView to remove and re-display the scrollviews each time the scroll animation ends.

To handle the "carousel effect" (the loop that occurs between the first and last documents), your UIScrollViewDelegate should check the contentOffset property and determine if we are on the last object. If the last object is displayed, render the first object on the right, just like any other. If the right object is then scrolled to, you use the code [scrollView scrollToRect: CGRectMake(0,0,scrollView.rect.size.width,scrollView.rect.sizeheight) animated:NO]; to move smoothly to the beginning. (Do the same for the first preview. Move the first and last on the left, process it the same way, if necessary).

Hope this answer helps. I will send the code when I can.

Good luck

Edit 2:

Now that I’m thinking about it, this whole paging control can be packaged into a subclass or category of UIScrollView. I will try to work on this.

+13
source

All Articles