I’m writing an app where one component is a checklist screen. The checklist has 4 or 5 logical subsections and I want to display each section as a separate view, with the user switching between views with forward and back buttons (and eventually with a swiping gesture event but that’s a separate issue).
Currently, I have a UIViewController class for managing the checklist logic, which loads the initial view from a xib. The xib contains all of the 4 or 5 views, and I can currently fairly easily switch between them just by setting up references to all the UIView objects in the UIViewController and calling
[self setView:viewNumberX];
within that class. However, this just abruptly switches the view, and doesn’t have the nice iOS-style animation.
The reason I did it this was was because I thought the proper paradigm was to have one UIViewController managing one or several distinct related views – in this case, my one UIViewController is managing all 4 or 5 subviews because they are all parts of the same checklist subject to the same checklist logic. I do notice that there’s a presentModalViewController:(UIViewController*)animated:BOOL method defined for UIViewControllers that does allow me the option of animating as I switch views, but this seems to require that I wrap my UIViews in 4 or 5 separate UIViewControllers, which doesn’t make sense to me. The individual views don’t have their own logic. Is there another way to get this functionality, or am I approaching this the wrong way?
If you want to have checklists you can swipe through, you can avoid both gestures and animations by using UIScrollView with pagingEnabled set to YES. Make the scroll view as wide as screen, and make it’s contentSize property as wide as screen * number of screens, then place each checklist inside that scrollview with x coordinate being something like padding + PageNumber * 320 (with pageNumber being an int and starting with 0). If you chose this approach I’m here if you need more details or sample code.