UICollectionView vs UIPageViewController - ios

I need to have different full screen views in my app. Very similar to how snapchat works. The views should be able to communicate between each other.
My question is: Should I use a UICollectionView with cells same size as the screen or should I use UIPageViewController?
Please provide some background info to support your opinion!

I think both have pretty different purposes.
UICollectionView is great to build a mosaic of views (think an image gallery for instance), whereas UIPageViewController is kind of similar to the flipping pages of a book. The latter seems to be what you need, but UIPVC doesn't seem to offer many tweaking/customizations, like custom transitions for example. In which case you may want to start from a UIScrollView with paging enabled to recreate something similar but with more potential. Here's an example.

Personal opinion: for this specific case I'd use a page view controller. Collection views have any things you have to consider, like when the device rotates you have to recalculate where you are, which cell you have to display, ask to scroll to the current cell, and if you are displaying a video or using the camera you might have to control it perfectly, otherwise issues will come.
However think about new features that might be added to your app, if you think you might show more than 2 items on screen, then you'd better choose a collection view.

A page view controller lets the user navigate between pages of
content, where each page is managed by its own view controller object.
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPageViewControllerClassReferenceClassRef/
So If you plan to swipe from one ViewController to another, go for PageViewController. If you plan to have only one ViewController that deal with a list of fullscreen image or so, go for a view controller with a collectionView, or maybe your own swipeView.

UIPageViewController use different view controller and load multiple controller so obvisioly take more memory as compared to UICollectionView. So if your required task is less calculation or step to do then its recommended to use UICollectionView, other case preferred way is to user UIPageController.

Related

Need Suggestion to Swipe through Views

I have a UITableView on didSelectrowAtIndex it pushes to a viewController which shows the detail on UIScrollView which is vertically scrollable.
Now I need that If I tap on any row it would be pushed to the same viewController and shows the detail of selected row,Additionally I need to have the Swipe Functionality to see the data for all rows in tableview instead of go back & select another row.
I know it can be achieved by UIPageControl or [scrollView setPagingEnabled:YES];,But I am wondering If there is any better approach to do the same or I should go with any of these two,If yes then Which one is better?
Please Help Guys.....Any Help would be much appreciated.
Thanks in Advance....:)
Of course, there are plenty of approaches to achieve what you want. You should keep in mind that UIPageControl has limitation on number of items (dots) displayed (over 20 items would overlap). Also, it would be appropriate to have next/previous buttons for the users preferring tapping buttons instead of swiping/panning. I prefer using UISwipeGestureRecognizers and buttons on toolbar for navigating between items.
The key, in my opinion, is to control how many UIKit controls are held in memory at the same time. However you implement this, you want to make sure that you have solution that holds UIKit controls for the currently visible child element only, or perhaps the previous and next ones, too, but not for the full array (especially if you're dealing with UIImageView objects).
One control to consider is UIPageViewController. At first blush, it might look complicated, but in reality it's quite simple and offers a nice way to swipe between various "pages" while not holding all of the pages in memory at the same time. See View Controller Catalog for iOS: Page View Controller.
If you decide to implement a scroll view with paging enabled, I'd suggest specifying the delegate and implementing the UIScrollViewDelegate methods to add and remove subviews as appropriate. This is historically what I've done, but I now lean towards page view controllers.
There are also a ton of third-party implementation of "infinite scrollers", which implement this sort of functionality, though I can't vouch for any particular one.

UIPageViewController: how to have "negative" spacing between view controllers (with scroll-transition style)

I have to implement a view controller (on iPhone, portrait only, full screen view) where the upper part of the view must have an horinzontal, paged scrolling behavior, potentially infinite.
I already used for similar purposes UIPageViewControllers, to take advantage of the datasource and delegate protocols, which are very helpul for manage memory and other stuff (keeping only 3 view controllers in memory, providing delegates to handle actions exactly when a transition is done and so on): so I think that in this case too this component is the best choice.
But here comes my problem. In the view I'm realizing, I have to let the user understand that he can swipe left and right to move to another view: a page control is not a good choice, since the scroll could be potentially infinite, so I would like to let a small portion of the views of the left and right view controllers to be visible.
Something like that:
link to the image (sorry I cannot include images in my posts yet)
Up to now I have not been able to figure out how to realize this. In the options during initialization, UIPageViewControllerOptionSpineLocationKey can be specified to set (from documentation) "Space between pages, in points": but this seems to work only with positive value, so that the space increases, while it ignores negative values that could reduce the space.
I hope there might be a solution using page view controllers, since at the same time I need to refresh a table view in the lower part of the screen when a transition is complete, and the delegate method of page controllers is ideal for this aim.
Maybe a collection view can be an alternate solution, but it is more complicated and I'm not sure how to obtain a behavior like the one I described to refresh the table view.
If needed I can attach some code and a screenshot of the prototype
Ok, I understand that this is not possible and why it is.
The datasource methods load, when needed, the view controllers that are before and after the current one. Making these view controllers' views always visible, as I desired, will require that the datasource loads more than one view controllers after (or before, depends on the direction of scrolling) the current one, to be ready for the pan actions (potentially, before the animation is ended by the user lifting up its finger, two view controllers "after" or "before" could become visible it my desired configuration), and this is not intended by UIPageViewController on iPhone, especially in portrait mode.
So actually, the only way to achieve that more than one view is visible in an horizontal-scrolling component at any time, is to implement a UIScrollview with horizontal paging and calculate the contentSize and other sizes accordingly.

Multiple Visible Pages in Scroll Style UIPageViewController

So what I'm looking to do is have a UIPageViewController that will end up displaying three view controller vies, one fully visible and then two as previews to the right and left. An example would be the iOS6 App Store:
Is doing this using a UIPageViewController set to UIPageViewControllerTransitionStyleScroll possible?
Basically I'd ideally like to have is a case where I can have three UIViewControllers that I recycle as the user pages through the 1- items in the list (with n being at least 50). I know an interface that behaves like this can be done with a UIScrollView with paging enable, but re-using views would take some view shuffling code that I'd rather not write if Apple has already done it for me.
I'm totally comfortable with the fact that this is iOS6 only, by the way, and also comfortable with alternatives, if they exist.
Thanks!
Check the new collection view. I think you may be able to create something like that with reusing cell etc.

iPad app designing

I need to create an app for ipad.Its something like the contacts app in ipad.(like an open book)
My doubts are whether they are using split view or two different views.
If splitview is used,how could we increase its width and style?
You can tell that they are not using a split view controller by turning the screen vertically: split view moves the master into a popover; contacts simply rotates, without popping the master portion out. I think that they use a single, highly customized, view for the contacts.
The background can be just a chunk of graphic or a picture. On top of that you'd add your own or Apples UI elements.
Each functional area should probably be implemented as a separate subview, ie. the UITableView on the left, the index on the right and so forth.
In your words - implement it as separate views not a split view.
If you want something like that (don't know why you would... the Contacts app is horrible) then you're going to look past the default set of UI elements provided to you by Apple.
UIViewController, UITableView are really the only two things you'd be reusing for something like that.

iOS: How to get swipe effect between views of tabbed view controller?

I keep seeing apps that appear to be tabbed view controller apps, where the user can easily swipe left or right between views.
How do I enable that kind of behavior?
Thanks.
The best and least hassle free solution I found is Andrey Tarantsov's ATPagingViev class. Works just like a UITableView, i.e. how many pages do you want, scroll horiz or vert. provide view for page, etc. Very easy and well coded. It's here: SoloComponents
It also has a recycling feature so it's memory stable.
If you refer to something like Apples photo app, it is using UIScrollView which has a property to enable paging.
If you define the views content width wider than your view's frame, you'll get the effect you describe. The view will page in steps of it's bounds width.
On each page you can place another view.
http://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html
Another option I found is SwipeView:
https://github.com/nicklockwood/SwipeView

Resources