Custom UIPickerView - Increase the no of items shown without scrolling - iphone

Picker normally shows 5 items without scrolling. Is there a way to increase the size of the picker to show up to 8 items without scrolling. Please help.

Kind of. UIPickerViews can only be a certain number of points tall (easy enough to find out what those are yourself), but you can fiddle around with the height of the items in the UIPickerView using the -pickerView:rowHeightForComponent: delegate method. If you return a small enough number, you could fit about 200 items in a UIPickerView all at once. They'd all be a single point tall, but you get the idea...

Related

tvOS UICollectionView scrolldirection

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.

UICollectionView doesn't bounce when datasource has only 1 item

I have a UICollectionView with a custom UICollectionViewFlowLayout. It scrolls horizontally and only shows one item at a time (full height). I have pagingEnabled = YES so that it sticks to pages.
The UICollectionView shows photos within a particular day. I initially had buttons to change the day +/- 1 day, but I thought it would be neat if the user could pull on the collection view past the first or last image (past a predetermined threshold) to change the day. I implemented this using the UIScrollView delegate methods and it works great...... if there are 2 or more items in the collection view.
This is hard to describe, but if there is only 1 item, it doesn't allow me to pull the item past it's bounds. I.E. there is no bounce to it.
I'd like to have this behavior, but I need to overcome this problem first. I'm thinking that if I removed pagingEnabled = YES and used targetContentOffsetForProposedContentOffset:proposedContentOffset:withScrollingVelocity, that I may be able to get it to work but I really enjoy the snappy behavior that paging enables. (They are mutually exclusive).
Any ideas on this?
UICollectionView has the properties alwaysBounceHorizontal and alwaysBounceVertical. Setting the horizontal to YES did the trick.
Thanks for #VaporwareWolf ,the answer is correct. I want to add a supplement that:
DO NOT forget setting the bounces property to YES at the same time(through storyboard or your code).

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. :)

How to select the last lines of a uitableview with many items

I'm confused about a question on uitableview. As u know, uitableview is a subclass of scrollview and can contain may items. However, I'm not able to select the last lines of a uitableview with many items. For example, I initialize a uitableview with 100 items and only 20 items appears once. So if I want to choose the 90th or 100th item I have to scroll the uitableview. However, the uitableview always stop at the 75 item. Although I can scroll the view to the 90th item, I cannot select it, that is, everytime I want to click this line, the uitableview jump to the 75 item again.
It is very confusing. Anyone have ideas about this question? Waiting for your ideas and help. Thank you very much.
Please check the height of your tableview in nib. If the height is defined greater than the view size in which it is loading, this situation might occur.
Try adjusting the height of the table view in its frame. Try reducing the height of the table view.

Is it good to show a UIPickerView with only small data size?

I have a view with a UIPickerView. The data for the UIPcikerView is runtime-driven.
The data size for the UIPickerView varies from 2 to 15.
Is UIPickerView still a good choice under these conditions?
I do not want to use a UITableView because there are some other controls I need to display in this view.
You don't think you can put other controls in a UITableView? UITableView is much more customizable than UIPickerView.
You could make a UITableView a subview if your view, and set its frame so it would occupy only a certain amount of screen-space. That way, your other controls would still fit. This way, you could even expand the UITableView's height while being scrolled, so the user could see more data, or shrink it if the number of options is small. Perhaps you can do the same with UIPickerView, but it would indeed look a little bit odd to have a UIPickerView with only two data items...