tvOS UICollectionView scrolldirection - swift

I am currently playing around with the tvOS SDK.
I need a collectionView with multiple section and many items, but only one row per section. So the user can scroll vertically through the sections and horizontally through the items in the single row.
When I set the scrollDirection of the collectionViewFlowLayout to ".Horizontal", the sections and the items are all just in one row, which looks pretty shitty.
Is there another way to get this behaviour? I thought about multiple collectionViews in a scrollView, but this seems too complicated and overheaded for me.
Thanks in advance!
Cheers.

I would think the best and possibly only way to get around this will be to a table view of collection views.
Somebody correct me if I'm wrong but that's the way I would probably go about doing it. Hope it helps!

I was having a similar problem, and it turns out the Collection View I was using wasn't tall enough.
It should be tall enough to accommodate two cells on top of each other plus min spacing in between, and if it is tall enough then the Collection View Cell will appear in the top left corner of the Collection View in storyboard.
Once it is tall enough setting the flow to horizontal should work the way you want it to.

Related

Uitableview horizontal as well as vertical scrolling.

I want horizontal as well as vertical scrolling whole table not particular cells.
Is it possible.?
Or should I implement simple view and reload again table.
Any Help?
There may be a way to do this however the Apple documentation states...
A table view has only one column and allows vertical scrolling only.
you can use collection-view for the purpose

Creating a scrolling grid of different width cells on iOS

I am new to iOS/Mac and ObjectiveC development and need a bit of guidance if someone could be so kind, so please excuse my ignorance.
The issue I have is I need to create a Grid view for a TV Guide where you have a vertical list of channel logos on the left that scrolls up and down, and to its right we have a horizontally and vertically scrolling grid. Horizontal scrolling doesnt move the channel logos which is fixed on screen, but vertically scrolling grid also scrolls the logos as you would expect.
Now being new to ObjC and iOS Frameworks, I was wondering which methods I should go down to implement this, Quartz2D perhaps? Or are their alternative simpler methods?
Whatever method is used, it needs to be quick with thousands of 'cells' across up to 600 rows; it also has to be memory efficient with out of view cells being disposed/reused as needed.
I am not necessarily asking for specific code (although that would be nice lol), just some advice on what methods to use so i can concentrate my education on those areas; if that is possible
Thanks.
It seems you do not really need two different scroll views / table views left and right, as the two sides should always scroll with each other.
Thus, just use a UITableView with a custom cell (subclass UITableViewCell) that has the logo on the left, and another scroll view (for horizontal scrolling) on the right.
Read Apple's Table View Programming Guide, and you will be on your way.

How to achieve this in an UIScrollView?

I want to display a list of items inside a UIScrollView , here for some items i'm having an images and some won't. The items having image have to be displayed along with image and the others just as a list of items, how can I achieve this? I mean, how to take care of contentSize, offset and all.
Any help is appreciated in advance.
Don't re-invent the wheel. Use a table view. This is a subclass of UIScrollView, optimised to display a list of items. You can use different cells for items with images and items without.
It really depends of what you want to achieve. You have to take in consideration, that sometimes is just better to have a UITableView with some custom UITableViewCell (for memory purposes).
Ok, so lets assume you want a UIScrollView with a vertical scroll. You will have items with some random images and others with no image at all. What you have to do, is just keep adding your items one after another inside your UIScrollView. You can do this with a while cycle. The only thing you have to pay attention is the measures of your items. So lets assume you have items with 140 of height. You can do something like this (I did not compiled this code):
float yReference=0.0f;
while(MyItem *item in arrayOfItems){
[myScroll addSubview:item.view];
item.view.frame=CGRectMake(0.0f, yReference+20.0f, item.view.frame.size.width, item.view.frame.size.height);
yReference+=140.0f;
}
Ok so now you have all your items added to your UIScrollView with space of 20.0f between them. After the while, you just set the correct contentSize of your UIScrollView:
myScroll.contentSize=vReference+20.0f;
(I added again 20.0f just to have a bit of space at the end)
You can check this tutorial if you need more help. Although he is adding the items horizontally the logic is the same.
P.S: In order for you to get more help, you should increase your acceptance rate. :)

Better to use UIScrollView or UITableView for horizontal buttons?

I have a page enabled scrollview on an iPad. On the first page, I have a child scrollview that scrolls horizontally through image buttons. The buttons scroll the outer scroll view to the correct page. Its basically like a table of contents that jumps to the correct page.
My end goal is to be able to categorize the buttons seen in the child scroll view. So there would be a segmented control that changes what buttons you can see. So maybe one category would be ALL, and another category would be A-M, and another would be N-Z for example.
My question is, should I use a uiscrollview or a uitableview?
Right now I use a scrollview and it is really easy to get the buttons in. I could implement the different categories kind of gimmicky by having all of the buttons in the scrollview and then just showing or hiding the buttons accordingly. I feel that it'd be bad memory usage though.
For a uiscrollview i was looking at using EasyTableView, butI'm not 100% sure if this is compatible with what i want to do or if it'd even be better.
Any ideas for what the best way to implement this is? Specifically, I'm not sure of the best way to change the buttons when I change categories.
Thanks!
Use a tableview when you are dealing with data that is best expressed as sections and rows.
I think for your situation I'd have a UIView subclass that can display the images you need for a given category. Stick that on the outer scrollview as needed. You can keep memory low by only keeping the currently visible view and the ones on either side on the scrollview. When you scroll to a new location you can recreate the view needed for that page, and the ones surrounding it. Then you release the ones that are far away and let the system reclaim their memory if needed.

How to implement UITableView with multiple columns and sideways scrolling

I'm thinking about how I could achieve this kind of UITableView: http://snapplr.com/c1x5
So it has multiple (separately selectable) columns in it which also differ in width. Apart from that it can also scroll sideways to see programs which broadcast later on the day.
Now, I'd like to know how you would implement this kind of feature. A scrollview wouldn't be enough, it has to somehow load newer data. And of course you need to be able to know what column in the cell has been selected.
Hope to hear some thoughts.
That is a custom view.
It's possible it could be a table view, with heavily customised cells, but that would have been a hell of a lot of work to get it scroll horizontally too.
It's more likely that it's a scroll view with a custom grid view type class that have support for arbitrary grid cell widths...
I'm sure if you write something like this you'll have a lot of interested people.
I just updated MDSpreadView, which is basically a UITableView that works both horizontally and vertically, floating headers and all, with an API very similar to UITableView.