How to create an iPad document preview interface, such as interfaces in iWorks for iPad

Willing to reward 500 bounty for a valid example.

I know that there are only 2 source code examples that can complete the document preview interface on the iPad, for example Those found in Number, Pages, etc.

infoNgen and OmniGroup Framework

Are there other examples? infoNgen is a good simple example, however, the code is very sloppy, very badly written, and very unorganized.

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

Update

I was able to break down the infoNgen project and use HTML preview to make a barebones document viewer, which seems to update the information in the document nicely and synchronize it with the preview The problem to be solved now is to make the document save when the application exits and restarts. 500 bounties can still be used for a working example, but I will not open the bounty unless there is a working example.

< /div>

“wrapper view” is the main view controller that will display the entire preview carousel.

“carousel” itself is a UIScrollView. Just create a scroll view and set the pagingEnabled property to YES. Place it to the appropriate size by setting the frame, and then add it to the wrapper view controller. You also need to add The contentSize property of the carousel view is set large enough. It is calculated by adding the number of documents to the width of the other two documents and multiplying the width of the carousel. If you want the documents on both sides to display a little, then multiply the number of documents by the scroll view Minus a few pixels from the width.

Edit

Actually, Googling this question kind of made me think of this post, which describes another way to achieve this. In essence , You wrap the scroll view in a custom UIView subclass, which forwards touches to UIScrollView. This is necessary because UIScrollView can only “paginate” for pages that are as wide as it. Use my “through a few pixels” “Adjust the side view” method, you end up with a good preview, but the offset will cause the preview to jump when scrolling. (I tried my method while putting the sample code together. As I just explained , It is useless.) Before using the custom wrapper, I will try one more method. (I want to know if the content insertion is effective.)

End editing

Please note, As Matthew correctly pointed out in the comments, you actually only created the 3 views you need, as described later.

The document preview you provide can be any object you like, such as You mentioned that UIWebView can be used to render HTML. No matter what you want to use to represent your thumbnails, the trick is to solve them.

I assume you have an array of objects, although you may be using Core Data to store your information. Show document previews, add them to the scroll view, but at the correct position along the “X” coordinate. To calculate the value, multiply the current document’s index by the width of the scroll view. Use the document preview’s setFrame method to apply this value. You also need to render the preview at the current and after, so you can get a smooth animation.

To handle rendering and scrolling, you need to put a wrapper into the UIScrollViewDelegate. Every time the scroll animation ends, the delegate should tell UIScrollView deletes and re-renders the scroll view.

To handle the “carousel effect” (the loop that occurs between the first and last document), UIScrollViewDelegate should check the contentOffset property and determine if we are in the last object .If the last object is displayed, the first object is rendered to the right, just like any other object. If the right object is then scrolled to, use [scrollView scrollToRect: CGRectMake(0,0,scrollView.rect.size.width, scrollView.rect.sizeheight)animated: NO]; The code seamlessly jumps to the beginning. (Do the same for the first preview. Render the first and last one on the left, and process it the same way if necessary).< /p>

I hope this answer helps. I will post the code as much as possible.

Good luck!

Edit 2:

Now I think about it, the entire paging control can be packaged into a UIScrollView subclass or category. I plan to try this.

p>

Willing to reward 500 bounty for a valid example.

I know that there are only 2 source code examples that can complete the document preview interface on the iPad, such as in Number, Pages, etc. Those found.

infoNgen and OmniGroup Framework

Are there other examples? infoNgen is a good simple example, however, the code is very sloppy, very badly written, and very unorganized.

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

Update

I was able to break down the infoNgen project and use HTML preview to make a barebones document viewer, which seems to update the information in the document nicely and synchronize it with the preview The problem to be solved now is to make the document save when the application exits and restarts. 500 bounties can still be used for a working example, however, unless there is a working example, I will not open the bounty.

< /p>

The “wrapper view” is the main view controller that will display the entire preview carousel.

“carousel” itself is a UIScrollView. Only You need to create a scroll view and set the pagingEnabled property to YES. Place it to an appropriate size by setting the frame, and then add it to the wrapper view controller. You also need to set the contentSize property of the carousel view to be large enough. Pass Calculate by adding the number of documents to the width of the other two documents multiplied by the width of the carousel. If you want the documents on both sides to show a little bit, then multiply the number of documents by the width of the scroll view minus a few pixels.

Edit

Actually, Googling this question kind of made me think of this post, which describes another way to achieve this. In essence, you wrap the scroll view in a custom UIView subclass This subclass forwards the touch to UIScrollView. This is necessary because UIScrollView can only “paginate” for pages as wide as it. Using my “adjust side view by a few pixels” method, you end up with a very Good preview, but the offset will cause the preview to jump when scrolling. (I tried my method while putting the sample code together. As I just explained, it didn’t work.) While using a custom wrapper Before, I will try one more method. (I want to know if the content insertion is effective.)

End editing

Please note that as Matthew correctly pointed out in the comments, you actually Only the required 3 views are created on the above, as described later.

The document preview you provide can be any object you like, as you mentioned, UIWebView can be used to render HTML. No matter you What you want to represent your thumbnails, the trick is to solve them.

I assume you have an array of objects, although you may be using Core Data to store your information. To display a document preview, Please add them to the scroll view, but in the correct position along the “X” coordinate. To calculate the value, multiply the index of the current document by the width of the scroll view. Use the text The setFrame method of the file preview applies this value. You also need to render the preview now and after, so you can get a smooth animation.

To handle the rendering and scrolling, you need to put the wrapper into the UIScrollViewDelegate. At the end of the second scroll animation, the delegate should tell UIScrollView to delete and re-render the scroll view.

To handle the “carousel effect” (the loop that occurs between the first and last document), UIScrollViewDelegate should check the contentOffset Property and determine whether we are at the last object. If the last object is displayed, the first object is rendered to the right, just like any other object. If the right object is then scrolled to, use [scrollView scrollToRect: CGRectMake(0,0 ,scrollView.rect.size.width,scrollView.rect.sizeheight)animated: NO]; The code seamlessly jumps to the beginning. (Do the same for the first preview. Render the first and last one on the left, if necessary Treat it in the same way).

I hope this answer helps. I will post the code as much as possible.

Good luck!

Edit 2:

Now I think about it, the entire paging control can be packaged into a UIScrollView subclass or category. I plan to try this.

Leave a Comment

Your email address will not be published.