Multiple CollectionViews inside a Scrollview - iphone

I am trying to create a horizontal scroller which starts with a collectionview (group1), when scrolling reaches the end of group1, I need another collectionview to page into view, and so on.
I am new to this and I can't quite figure out how to solve it.
I have no problem creating a scrollview which adds three different views, however since the contentsize is set like so: self.scrollView.contentSize = CGSizeMake(320*[controllers count], 460);
A specific view only displays as many cells as it can fit, leaving the rest behind the next view as you scroll.So to clarify this, I need to scroll inside one collectionview before the scrollview pops me over to another collectionview.
Any help or pointers in the right direction would be highly appreciated.

Related

how to set the content size of a scrollView Dynamically

I have a scrollView and on that scrollView, i have many labels and textView along with one tableView. scrollView is working perfectly fine when the no. of rows are less in tablView but if tableView have more number of rows then i am not able to full content and even i am loosing lots of information in tableView because the tableView isn't scrollable. i have added all the lables, textView and tableView as a subview of scrollview. Can anyone help me in that so i can get full tableView and make it proper scrollable.
Here is my code to set the content size of scrollView.
float maxHeight = 0;
for(UIView *v in [self.scrollView subviews]){
if(v.frame.origin.x + v.frame.size.height > maxHeight)
maxHeight = v.frame.origin.x + v.frame.size.height;
}
self.scrollView.contentSize = CGSizeMake(_scrollView.frame.size.width, maxHeight+100);
First you'll need to resize your table, so that it fits all the rows (since as you said, it's not scrollable). I believe that doing so will make all your rows to not be reusable, so if it's a big table you may get performance issues. Also be aware of #David H's answer, so if you really want to do this, you might be better of using another UIScrollView instead of the UITableView (it won't bring much benefit either way).
Second, you'll need to move all the views beneath the tableview, so that they won't overlap. An easy way to do this is to have those views put together in a different view, so that you only need to move one view instead (in this case however, you'll also need to resize that view accordingly).
Finally, instead of looping through all the scrollview's subviews, it should be easy enough to keep track of the view that is closest to the bottom (this depends on how you generate and add the views to the scroll view).
A tableview is a scroll view subclass, and generally Apple says adding it to another scroll view will cause problems. That said there are ways to make it work. Search here or on google for terms like "how to put a uitableview in a uiscrollview".
EDIT: to make it not scrollable you could put a transparent view over the table view that stops or eats touch events.
self.scrollingView.contentSize=CGSizeMake(320,372);
Try this.

Gain control over scroll view

I have a scroll view which contains several objects like text fields,labels,switch etc..Now as we are aware that a table view by default provides control for user to scroll and stop where ever he/she wishes to.Like wise I want to achieve the same control for scroll view to stop any where at any point of the view.But my scroll view is not behaving properly,It is not stopping when scrolling is in progress.In other words scroll view is lacking smooth behavior.Instead it is scrolling to the extreme end and showing the 2nd half of view or it is appearing as if it is scrolling and its making the view unchanged i.e. to the start point and showing the view as it is.May be this description might sound a little bit confusing,but in one word I want my scroll view during scrolling,to stop at any object in the view,just as in the case of a table view,so that it is user-friendly.
I have set the frame and content off set to the scroll view in view Will Appear method as follows:
-(void)viewWillAppear:(BOOL)animated
{
scrollView.frame = CGRectMake(0, 0, 320, 460);
[scrollView setContentSize:(CGSizeMake(320, 815))];
}
Note : I have a tab bar controller on the bottom of view,to navigate between controllers.
I have just gone through the UIScrollView as well as delegate class references.I have come across paging,scroll view will begin dragging,scroll to row at index path etc.. methods.Out of these what method I need to implement and what is the logic I need to write.
Want some valuable suggestions.
Thanks all in advance :)
OOps....its my mistake :(
We need to disable paging enabled property or set to no if it is set to true or yes either in IB or in our code snippet....thanks :)

Can we add a scroll view inside UITableViewCell?

I have requirement where I have to show some images which are differentiated according to Groups they belong to. I have used a table view to view images listed under groups. User has to scroll horizontally to view more images in a particular group.
Can we add a scroll view to tableview row to allow user to scroll list of images horizontally?
I searched a bit, some comments say its not allowed in apple's HIG some comments say
You can add a UIScrollView to a UITableViewCell and as long as you set the contentSize property of the UIScrollView correctly then the UIScrollView will scroll correctly in the horizontal axis
May I get any confirmation on this ??
Or any alternative approach to achieve horizontal and vertical scrolling for different data without using tableview
Yes it is definitively possible and reasonable.
Here is an excellent tutorial by Felipe Laso that explains it step by step:
How To Make An Interface With Horizontal Tables Like The Pulse News App: Part 1
How To Make An Interface With Horizontal Tables Like The Pulse News App: Part 2
BTW, the approach described in that tutorial is way more efficient than adding a UIScrollview to each cell.
Of course you can add scrollView in tableView.
UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 100)];
[cell.contentView addSubview:scrollView];
Now you can set properties for scroll view accordingly.
Sure, this is possible. A UIScrollView inside a UITableCellView will work fine - the HIG says no, probably because it'll be hard to use. The user would have to accuratley scroll either up/down, or left/right and it might be annoying. Shouldn't take long to knock together a quick test.
I have an app with 2 scrollviews - one that allows horizontal scroll, and then inside that another scrollview which allows vertical scroll. The idea is that the user can flick up/down a page, then also flick left/right across pages.
It's not that nice to use, but it's what my client wanted ;)
To make a UIScrollView only respond to horizontal or vertical scroll is all about setting the correct contentSize. Hope this is some help.

UIScrollView always bounce upwards and does not show scroll bar in iphone

This is probably simple but I do not seem to get it to work. I have a view and inside it I have a scroll view and inside it I have a view with some labels and a button. the height of the text inside the labels changes according to some condition so I need to scroll down to see it. But whenever I try to scroll down it bounce back up without giving me a chance to view the rest of the view.
Basically, I want when I scroll down, the view to remain down as it normally should. Besides I do not see the scroll bar at all when I'm scrolling.
I know I probably do not understand how scroll views work, so I'd appreciate any help to explain to me the behavior of scroll views.
P.S. I built my whole view in a nib file and this specific setup That I mentioned at the beginning is based on a suggestion from one question I read here.
Thanks, Mohsen
you need to set content size of your scroll view
[scrollView setContentSize:CGSizeMake(360,1000)];
you can make the content size dynamic as per your calculation.

iPhone: How to Place a Scrollview Inside of Tableview Cell

I want to put a scroll view inside of the table view cell. I have a number of buttons in one cell of table view and I need to scroll that cell to show the appropriate button.
If you want to use a vertical scroll view then I wouldn't suggest you doing it because, as TechZen wrote, there will be a mess in this case.
If you want the inner scroll view to scroll horizontally then it might be achieved by 2 ways:
Implement a custom table view cell that will include a scroll view inside it.
Add a scroll view as a sub-view to your cell that you will return from tableView:cellForRowAtIndexPath: method.
I suggest you to use the second approach.
There are plenty of examples online. Usually the sub-views are labels or image views, but it is not complicated at all to add a scroll view instead...
I don't think you can do this. It would require nesting of scrollviews which isn't really supported.
Even if it was, it would be very difficult for a user to know which scrollview they were hitting with their pudgy finger. Remember, you don't have the one pixel precision of a mouse on the iPhone. You have an area of at least 15x15 pixels. You don't have a scroll bar but instead just drags anywhere on the screen.
Instead, you should use a master-detail pattern. Selecting the cell in the tableview pushes a detail view which has the scroll view with all the buttons.
Why do you want to do it like this?
I think the best idea is to draw your table view manually above your uiscrollview. I did it, and it works. It just takes more effort and drawing accuracy. But that takes a lot of time. :)