I want to use a collection view thats horizontally scrollable along the bottom 25% of my screen full of pictures and then use the top 75% of the screen to display information about the selected cell (zoomed in picture, caption, people in it, etc.) of the collection view. My question is how to go about implementing view controllers in this situation.
Will I need a UIViewController to handle the whole screen and UICollectionViewController to handle the collection view (how do I get them to work together?) Or could I implement the whole screen with just one view controller? (if so, which one?) Should I use a custom CollectionViewController with one section being my main info, and another section being the bottom scrollable part?
No, just have one UIViewController and add the UICollectionView as a subview. Then set the dataSource and delegate and tell it to reloadData. If it seems too easy, you're overthinking it.
Related
I just want to know what exactly should I use in storyboard UI so that I can create multiple views which can replace one view with the after a click of button:-
Replacing first view with second in this way
And not this way
You can use a CollectionView as the Header of a TableView if you want a UI shown in first image.
TableView will be having Chat options and the Collection View will be having images as you have in the given picture.
Quick Overview :- TableView only supports Vertical scrolling which is best in your use case.
Collection can support both vertical as well as horizontal scrolling. So basically what you can do is have a collection view of height as much as you want as a header of your tableview. So when the user scrolls through your tableview your scrollview will also move up just like we have in facebook and instagram stories.
Even if you have more images in collection view then your predefine height set the scroll mode as you prefer horizontal or Vertical so that user can have a look at everything you have in there.
Edit :- After editing your question this can be done for what you're looking :-
You need a Navigation Controller. Here's the Navigation Controller Push and Present of the answer which shows in detail how you can achieve that.
By doing Push you can achieve what you want (first image) and by doing present you'll achieve the second image result.
I need to have iOS app with screen like this:
screen
The idea is when user start to scroll down the first UIView to move up until the second UIView reach the top where it will stick and only UICollectionView will continue to move up.
Currently I'm using this structure
UIScrollView (main scroll)
UIView (some banners)
UIView (UISegmentedControl)
UICollectionView (grid with items, scroll is disabled, main scroll is used)
I manage to do it, but I needed to set UICollectionView height constraint manually in the code (calculated based on all items in grid) in order to appear in UIScrollView (everything else is handled by AutoLayout in Storyboard). The problem with this is that UICollectionView think all cells are visible and load them, so the whole recycling & reusing thing does not work. It's even worst because I use willDisplayCell method on UICollectionView to load more data when last cell is displayed, but now it load all pages at once.
My question (actually they are 2)
How can I fix the issue above?
What is the right way to achieve this functionality? Maybe my whole approach is conceptually wrong?
Collection view is a scroll view itself. So maybe you could have same functionality only with Collection view with sections or even custom layout?
I am trying to create a UI just like Facebook's comment screen on mobile.
I got a UITableViewController on my storyboard. I need to insert a view docked to the bottom of the screen to place a text field. Since the tableview is taking the full screen, I can't do it on storyboard and I think I need to do it programmatically but how? Should I modify the constraints that stretch the tableview to the edges and insert the views or what?
Thanks.
You can always add table view to normal UIViewController and below it add another view.
In shorts, my desired screen layout is basically a user profile (iOS 7 + Xcode 5). I used UIScrollView as the top level view. The reason is that I want all its subviews to scroll (user info view - the view with a profile image and some buttons you see on the screen, and the photos collection view - the one with black background) when it is scrolled.
The region with black background will show user photos. I'm wondering if I could use a UICollectionView here, or there's a better way to implement it. The UICollectionView in this case shouldn't be able to scroll itself, it just shows all cells, while the scrolling work is handled by the outermost UIScrollView.
I read following posts:
UICollectionView inside of UIScrollView
UICollectionView in UIScrollView -> Scroll Order
iOS 7 Collection View inside Scroll View
Some said it's not possible (or at least, weird) implemeting UICollectionView inside UIScrollView because UIScrollView is UICollectionView's superclass which leads to unexpected behaviour. Some said it should be implemented in another way (but I didn't see a clear suggestion).
Yes, you can put a UICollectionView inside a UIScrollView. iOS has fully supported nested scroll views since iOS 3.0, and UICollectionView is a subclass of UIScrollView. For example, check out the App Store app on your iOS device. The screen scrolls vertically - it's either a UIScrollView or a UITableView (which is itself a subclass of UIScrollView). And each row of icons scrolls horizontally - each row is a UICollectionView.
However, it's not clear why you need to put a collection view inside a scroll view. It sounds like you only want the photos view to scroll, so just make the photos view be a collection view. Why do you need to put the collection view inside a scroll view?
UPDATE
Just use a collection view. Set the header of section 0 to the profile info view. You don't need a scroll view.
If you put all the photos in one section, you can set up the header in your storyboard with no code. If you use multiple sections, you'll need to implement collectionView:layout:referenceSizeForHeaderInSection: in your delegate and collectionView:viewForSupplementaryElementOfKind:atIndexPath: in your data source.
I am working in a profile ViewController. This profile has a main image in a UIView subclass and a CollectionView gallery with some images. I would like to be able to scroll up the UICollectionView and move the UIView too, and if I scroll down, I want to watch again the UIView when the collectionView first item is showed again.
I have tried to do this adding the collectionView and the UIView to a ScrollView, but the UIView only scroll up if I touch it.
In this picture you can see my problem
Thank you in advance
You need to make the view at the top a Header View of the collection view.
Essentially it needs to be an actual part of the collection view if you want this action. (That's the easiest way anyway).
So the collection view will take up the whole screen but it will have a header view. Then when you scroll the collection view the header will move out of view and then come back in when you scroll down again.