Embedded UIcollectionView scrolling inside UITableView Cell - ios

I have UICollectionView inside Static UITableView Cell. I want to ask how to enable vertical scrolling in UIcollectionView interface builder. what are the right settings to achieve that?

You couldn't see any scrolling in the Interface Builder:) Only when compiled.
Yes, you have right set - Scroll direction to Vertical. But... I guess, this is doesn't work for you?
If you set custom layout for collection view in code - you have to setup it.

Related

How to make a Horizontal and vertical scrolling TableView in iOS using storyboard?

here is my design structure
I was wondering about creating a horizontal and vertical scrolling tableview. I have tried a tableview inside a scrollview but I failed miserably. What to do?
I use swift4 but I wanted to do in storyboard.
The nature of content is like an excel sheet with lots of horizontal and vertical scrolling rows and columns of data.
Actually you can do this using a hack. Put the tableView inside a scrollView. Then you should give a dynamic width to the tableView by specifying a width in storyboard for tableView or any child view of that scrollView(So we get the horizontal scrolling).You have to adjust some constraints depending on your requirement
Mine worked fine but as many users have said try a collection View if its easy
Note. There is a default scrollView within a tableView, So adjust your height of tableView in a way so the scrollView of tableView work and not the parent scrollView, while scrolling from top to bottom
Instead of using TableView try using collection view, there you can use horizontal and vertical scrolling using storyboard?
Try to use collectionview instead of tableview.
If your requirement demands use of tableview anyhow, then you can use tableview within scrollview.
In tableview within scrollview approach, you need to distinguish your parent scrollview as well as tableview's scrollview. Try to differentiate parent scrollview and tableview's scrollview with different tags. Because both scrollview will call delegate methods of viewcontroller, if implemented. Just check tag of scrollview in all delegate methods of scrollview and perform action accordingly.
As per my understaing you want a view which you want vertical scroll view and horizontal inside it.
So here my suggestion is to use UITABLEVIEW for vertical scrolling and UICOLLECTIONVIEW for horizontal scrolling inside tableview
Both will work fine

How to put UIView inside of UICollectionView?

I want to put my UIView inside of UICollectionView(on top) that on scroll it scrolls with UICollectionView content. It's possible to put it on header part in UITableView, I did it, but in UICollectionView I cannot achieve the same effect. How can I do it?
I have created GitHub repo with sample. If anyone could help me with it.
In UITableView I add UIView inside of UITableView and it stays there, but in UICollectionView it stays behind of UICollectionView. I want that it(UICollectionView sections) will stay under the UIView and on scroll all(UIView & UICollectionView sections) will scroll together.
There is no such thing as collection view footer or header, because the layout can be very different depending on your needs, but, you have a couple of function that can help you for example:
registerClass(_:forSupplementaryViewOfKind:withReuseIdentifier:)
or
registerNib(_:forSupplementaryViewOfKind:withReuseIdentifier:)
depending if you are using a nib file or not.
I'm not sure but you will also need to provide the height of the view in the layout delegate
UICollectionViewDelegateFlowLayout
you can do this by dragging your UIView on to your cellidentifier of UICOllectionView
Like i did see in snapshot:
here View is my UIView which i added to UICollectionView and it scroll with the CollectionView

UITableview frame changes after scrolling thanks to Autolayout

I'm working on a application where I have a UITableView inside a UIScrollview.
The TableView will display current games players are in, its inside a UIScrollView. I dynamically add cells to the UITableView for each game, but when I scroll the UIScrollView, the tableview inside it snaps back to its size set in the storybuilder.
This is because of autolayout, when I disable it, it doesn't happen anymore. However I do like autolayout for other views in my app. So my question is, how can I fix this problem?
Maybe someone can help me get on the right track.
Thanks
EDIT
I think I must explain my situation more, I will use an image where I can display what is happening
Explanation
Before and after scrolling.
As you can see I use the scrollview because there can be many games, so you'll have to scroll down to see them all. The TableView is just to hold the data, scrolling is disabled on that. After scrolling the TableView that says "JOUW BEURT" snaps back to its size set in the Storybuilder. This is because of auto layout like I said, but I don't know how to fix this.
You shouldn't put a tableview inside a scrollview as a tableview itself contains a scrollview and causes issues just like you are seeing when you have a scrollview inside a scrollview.
Remove the scrollview and this should fix your issue. If you are wanting to put content above the tableview or where you scroll down to view the tableview cells etc, consider adding a tableview header view that is added above the tableview.
Why did you place UITableView inside UIScrollView?
Check below
Check your constraints of UITableView and UIScrollView
Placing UITableView inside UIScrollView is somewhat strange
EDIT
You will just need to remove the scrollview and enable scrolling feature of the tableview. that will fix it
UITableView is already a subclass of
UIScrollView

Mixing UIScrollViews and UITableViews

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!

UITableView and Another View inside ScrollView

I have UITableView and UIView(used to show image slideshow) inside UIScrollView. The tableview is dynamic and i want to automatically adjust height of table view to show all the cells(and disable scrolling of tableview) and scrollview should show both slideshow and tableview and could be scrollable, I know how to do this with code but i want to know if is possible to do in Interface builder(without using iOS6 auto layout) using previous(iOS5 and early) autoresize method in the xcode size inspecter tab(see image)
I think this is hard to do only using interface builder.
You can set your objects via interface builder. But for maintaing scrolling conditions you need to do it programmatically. Also for table view height to be dynamic you need to be done programmatically.

Resources