I have a viewController with some text and under it a UICollectionView (about 50% of the page).
My problem is that when I scroll on the collectionView just the cells are being scrolled and not the whole page (the text + the collection cells).
You can think about it like on Instagram profile page (half info half collectionView), when you scroll on Instagram everything is being scrolled and not just the collection cells.
Anyone knows how can I do it?
Thanks!
Add the text content as separate cells on top of the UICollectionView.
Preferably, create a different section which would contain the cells with the top text.
Keep the backgroundColor/backgroundImage of these cells plain to give the effect that they are simply added as UILabels on a form. Doing so will also differentiate from the rest of the actual UICollectionViewCells.
Now, when you scroll the UICollectionView. It will give an effect that the text along with the cells are scrolled.
In Attribute inspector > Scroll View > check Paging enable
Thats because your text/UILabels doesn't belong within the UIScrollView of your UICollectionView, thus it will not be scrolled when the collectionView is. You could create a UICollectionViewCell for your text, include it within your collectionview and expand the collectionView to fit the screen or use a UICollectionViewController
Related
I am looking to create a certain layout with a collection view. Where there are 2 sections to the main viewController, the first being static on the page, and the second being a collectionView which moves over the other when the user scrolls. I want the collectionView to have a limit of how much it cover the static content (it should have a minimum and maximum inset that it can covert). The collectionView has a button which "hangs over" the static section. I have attached some images to describe this further.
I have thought of a few ways to achieve this, the most promising being a collectionView with a top contentInset of the 'max scrolled down' height. This would show the content underneath and allow the collectionView to be scrolled up and cover it. the button which "hangs over" would be a subview of the collectionView and would also show the rounded corners and drop shadow.
Problems:
couldn't continue scrolling the collection view whilst also pinning the header to the top
If anyone has any suggestions of how to go about this, please let me know! Thank you.
I'm trying to build something close to this
As you see here , when you scroll down , all the view scroll
This is my view :
when i scroll down , only the second collection view which scroll
My view is like that :
I tried to use UIScrollView , but always the same result ?
Any idea how to make this kind of layouts ?
Thanks.
You can accomplish the first layout (red cells) with a tableView with cells that contain collectionViews (one horizontally scrolling collectionView per tableView cell). However, in your case, it looks like you want the top part to scroll horizontally, and have the whole thing to scroll vertically. I would do something like this: Have the whole thing in a collectionView with 2 types of cells. The first type would be most popular place cell that contains a horizontally scrolling collectionView. The second type of cell would be the individual hotel cells.
The layout on the storyboard would look something like this
I need to horizontally scroll through a list of thumbnails at the bottom of the screen that shows all the user's recently taken photos / videos.
I created a UIScrollView with a UITableview inside of it.
Is this the correct approach because I can't seem to find an override method in its superclass for scrolling direction?
Most of the topics I can find online deals with putting a UIscrollview inside a TableCell, which will not work for my specific application?
The hierarchy is:
View > Scroll View > Table View > Table Cel > Content > PhotoThumbnail
Below is a screenshot of what I'm trying to do:
I am not really sure why do you want to use UITableView for horizontal scrolling which lay out there cells in vertical manner. If you want horizontal scrolling I would recommend using UICollectionView where cells can be added horizontally or vertically or both.
Still if you want tableview to be scrollable in horizontal direction I would suggest you to check this project to get inspiration or using it.
https://github.com/alekseyn/EasyTableView
Instead of using UITableView you can use UICollectionView to achieve the desired result i.e, horizontally scrollable cells with imageView and other elements that you need.
If you look at the Featured tab of the Apple App Store app on an iPhone 6, there is a unique UI layout that I can't figure out how to replicate.
At the very top there is a navigationBar. Below this there is a UIScrollView that animates through a number of featured items. Below this is what appears to be a UITableView with a number of custom programmed cells.
My first guess was that the UIScrollView at the top was added to a custom cell at the top of a UITableView. If you swipe up the UIScrollView moves with the objects below like it is a cell. You can see that the vertical scroll indicator starts at the top of the UIScrollView.
The part that is unique is that if you swipe down, the objects below the UIScrollView move down like a UITableView and the UIScrollView stays in place. This means that the UIScrollView is not a custom cell at the top of a UITableView.
I tried making this work a number of different ways but I can replicate this. Does anyone know how this can be done?
You can use a tableview header,the header is a scrollview
If you scroll tableview up,just use tableview default behavior,the header will scroll up.
If you scroll down,use UIScrollViewDelegate to calculate the tableview header new frame,and adjust it.So it remain at top
Not sure if I got you correctly, you may use UICollectionView as vertical scroll. Then, you create a custom UICollectionViewCell, each with horizontal scroll.
I haven't tried it though but done something similar to this. Hope you find a way!
I have a set of pictures organized by name like below which indicates where a photo should be in the view:
Image_PPRRCC.png
PP: Page No. of photo
RR: Row of photo
CC: Column of photo
The app has three kind of views as below.
1- View the whole page. Scroll horizontally to view next page.
2- Single image view. When user has double tapped on a picture in whole page view. Scroll horizontally to next photo.
3- View a row of photos. When device is in landscape mode. Scroll vertically to view next row and scroll horizontally to view next page.
I tried using a UICollectionViewController and put the images in dynamically sized cells sorted by their names. The problem was with horizontal scrolling. When horizontal scrolling is selected the items are populated vertically in a UICollectionView and the sorted array of image names and position of each photo in row and column of a page is messed up.
Then tried to use a UIPageViewController with a UIView for each page with a UICollectionView in each page to show images of corresponding page. But I couldn't manage to setup the views for it.
So any suggestions how to setup the views? Which method is better for the desired interface of the app? The one UICollectionViewController method or UIPageViewController method? Or maybe a better method?
use #property (nonatomic) UICollectionViewScrollDirection scrollDirection;
The grid layout scrolls along one axis only, either horizontally or vertically. For the non scrolling axis, the width of the collection view in that dimension serves as starting width of the content.
read more about UICollectionViewFlowLayout in https://developer.apple.com/library/ios/documentation/uikit/reference/UICollectionViewFlowLayout_class/Reference/Reference.html#//apple_ref/doc/uid/TP40012182-CH1-DontLinkElementID_4