ios view transitions animations, page curl - iphone

i'm new to the ios sdk and i'm developing my first app. i need to implement a curl transition between multiple views; giving the user the impression they are reading a book. the documentation only talks about doing it between two views in a single view controller. like i said i need to implement this with a stack of several views. do i need to use more than 1 view controller? if so how? or do i have to use 1 view controller but use say 10 views in a stack? again how would i go about doing this.
would greatly appreciate your help.

Ideally, you would use only two views for this: one for the view being animated (to an offscreen position), and one for the view underneath. To handle multiple flips, you would animate the top view to its offscreen position, then fill it with the data for the page underneath the current page and then insert it underneath the current page. For the subsequent flip, you would animate the current off the screen, etc.
You could alternatively use a number of views that matches the total number of pages you want to display. This might make your coding simpler, but it would eat up a lot more memory.

Related

Best way to show a small view/dialog over an existing screen?

All my views/pages in apps so far have been full screen UIViewControllers that i push and pop from the stack.
I see some apps create a new view/window that appears about the 1/3 the size of the full screen on an iPad, containing tables of items to select or other UI elements. They are commonly used to allow users to filter the current view they were on.
Seeing them in apps, I guess that they are just adding a UIView to there current screen and change its frame depending on where on the screen they want it to appear.
Or am I wrong? Is there another/better way to do this?
I guess you are talking about UIPopovercontroller. There are several tutorials to build the same.check this. Hope that helps you.
It's a little unclear from your question what the view looks like.
If the view is "attached" to a UI element (has a little triangular arrow connecting it to, e.g., a button) and goes away if you tap outside it, then it's a view presented from a UIPopoverController.
If the view overlays everything and dims the content behind it, is likely a model view controller presented with a presentation style of ether page sheet or form sheet.
Both are common and easy to set up. See the class documentation I have linked.
In most cases, these are probably normal modal view controllers whose modalPresentationStyle property is set to either UIModalPresentationPageSheet or UIModalPresentationFormSheet.
Yes you can make your own UIViews and just add them as subviews. Another option for iPads specifically is with the UIPopoverController class.

iPhone transition effect to reveal an updated version of the same view

So I have an app on the main page is details of the current date.
The page has left and right buttons to move to previous and next dates and a table of info below. This all works.
However I want to add a swipe between the days, now doing the swipe control is easy and I have done that.
However I want to give the visual indication of a swipe.
I am not changes views , I am simply refreshing the current view.
If you look at myfitnesspal (free app) , that swipes between dates in the same way I am after.
It scrolls off (a copy?) of the screen to one side , slides in the latest version to replace it.
I am at a loss on how to achieve such a simple effect without going for multiple views which unless I am misunderstanding would be over complex.
Use a UIPageControl, here is a tutorial of how to implement one using only two views: Cocoa with Love UIPageControl sample
Both views can be identical, (instances of the same Class, created programmatically or 2 CustomView outlets on IB)
This way you only need to update the view that's going to slide in the screen.

Code design question using UIViewControllers (drawing PDFs page by page) - best practice?

I have written a little PDF viewer which is supposed to show PDFs page by page to reduce memory usage.
It consists of a PdfViewController which shows a specific page of the PDF (using UIScrollView, CATiledLayer).
Now the (maybe stupid) question is: if I want to show the next page (using a swipe gesture ot whatever), how would I do that? Should my controller handle it and update its views (which is a horror becaue CATiledLayer seems to crash as soon as you look at it :-)), or should there be an "outer" controller which generates a new PdfViewController for every page flip (the more flexible aproach)?
What is the best practice in these situations? Looking at UINavigationController, you're supposed to push a new UIViewController for every level. But there, all controllers being pushed may be different. In my case, all pages are using the same controller.
You likely shouldn't use the UINavigationController for that. In general, the UINavController should be used for drill-down operations, where you have a limited set of items to be pushed.
In your case, I think the best option is to use a large UIScrollView which will take care of the pagination and then just create a new UIView with the CATiledlayer inside.
I created for my app Quicklytics a PagedViewController class that does most of that for you. You basically create a PageDataSource that creates the UIViews for each page, and handle it over to the control. You may not use this exactly as is on your code, but it'll give you a good idea on where to go:
https://github.com/escoz/monotouch-controls/blob/master/UICatalog/PagedViewController.cs
Hope this helps you.
Here are two useful resources
Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints? collects a whole lot of information on displaying pdfs.
https://github.com/vfr/Reader a basic pdf reader for ios that does what you are trying to do.
In terms of whether to use nested UIViewControllers I would recommend against it, however if you do you should be aware that they will not handle rotation very well (I don't think they receive orientation change events) as well as viewDidAppear and other view lifecycle events, also make sure only to display modal view controllers from the root view controller otherwise they won't show properly (I had issues with them appearing in the wrong orientation in landscape, or in the wrong position).
In the app I built I used one UIViewController to manage the display of the pdf and I subclassed NSObject for any other "sub" controllers to make it more manageable. For example I had vertical scrolling as well as horizontal scrolling of pdf pages. My first attempt used nested UIViewControllers however I had issues with orientation till I rebuilt using controllers subclassed from NSObject for managing vertical slides.

iphone search swiping

I am wanting to have half of a view taken up by a page control. The page control will allow the user to swipe from left to right on a selection of 5 different table view lists.
Is this possible?
What is the best approach.
Will each table view that will be put into the page control need its own controller? Or am i totally off the path.
The example i want it flow like is the screenshots of apps in the app store app details page. Except for screenshots i will be showing lists of data.
Thanks in advance
It sure is possible. Use a scroll view with paging enabled.
And you dont need to have separate controllers for each table view. You can handle multiple tables in a single TableViewDelegate, as all the delegate methods have the table view a parameter.
Check PageControl and ScrollViewSuit code samples.
And about covering half the view, well, your scroll view can be any size.

Nested UIScrollView-iPhone photos application

I have been facing the same nested UIScrollView problem for long time.I tried some open source codes like Scrolling madness ,three-20 and others but all fails finaly.I am trying to make a photo Viewer application same as iPhone.For that I have created the structure like this:-
1)one View controller.
2)on view of view controller one UIScrollView (i.e inner/parent scroll view) as a child.
3)on inner/parent scroll view number of child scroll views(i.e. outer/child scroll views) ,each represents one page of photos application.
4)On each scroll view one image View on which i am displaying my image.
So what I want is when user scrolls the outer scroll view it should scroll horizontally with all the child views so I will get the look and feel of paging in photos application.Also when user is on one specific image(i.e. child/outer scroll view) he should be able to zoom in/out,swipes and perform single/double tapping.I was able to make it work in sdk 2.1,but it dosnt work since sdk 3.0.Please tell me the idea behind your project.Means which scroll view you are subclassing ,in which view to detect touches.How this completely child - parent relation should be.
If possible provide any sample code also.
There is a WWDC session from 2010 that deals with this very issue.
Here's the short of it:
You need a single scroll view that is paginated and scrolls horizontally. Each "page" of that scroll view is another scroll view containing a photo.
First, it looks like you want to subclass UIScrollView? Every interaction method you need is provided for you in either the delegate callbacks or the touch methods. (Many of Apple's more advanced classes, such as UIScrollView, react poorly to subclassing.)
Second, it sounds like you have a first responder problem. IOW, your innermost scrollview isn't getting the first crack at the touch events.
Andrew
I also struggled with this for a long time trying samples you mentioned. I could finally figure it out with the samples provided by apple (iphone dev center).
http://developer.apple.com/iphone/library/samplecode/Scrolling/Introduction/Intro.html
http://developer.apple.com/iphone/library/samplecode/ScrollViewSuite/Introduction/Intro.html
The first one is pretty basic and probably what u already have. The second one is all about zooming, etc. Just study these and the samples you already have, I think you will be able to figure it out. On specific topics just come back here search for answers or post another question.
EDIT: I forgot this one check out these examples by Andrey Tarantsov hosted on github. This is what you want... http://github.com/andreyvit/ScrollingMadness