Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal and vertical scrolling in a UITableview [closed]

I want to make a lineup for a festival. You can see what I want to achieve below here. enter image description here

You can scroll in every direction ,horizontal - vertical and from left to right corner (don't know the proper word in english).If you scroll in one section ever other section should scroll with it.

My question is know how can you achieve this? I'm searching for days to get this working but don't find a good solution...

like image 816
Steaphann Avatar asked May 08 '13 08:05

Steaphann


1 Answers

The row in the UITableView doesn't scrolls itself inside the UITableView. one solution Is to use an UIScrollView and then inside add the UITableView. This UIScrollView will have the same size that your UITableView have now, but the UIScrollView contentSize property will have the same height but it would have a greater width.

enter image description here

UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(x, x, x, x) style:...]

[scrollView addSubview:tableView];

// Set the size of your table to be the size of it's contents 
// (since the outer scroll view will handle the scrolling).
CGRect tableFrame = tableView.frame;
tableFrame.size.height = tableView.contentSize.height;
tableFrame.size.width = tableView.contentSize.width; // if you would allow horiz scrolling
tableView.frame = tableFrame;

// Set the content size of your scroll view to be the content size of your 
// table view + whatever else you have in the scroll view.
// For the purposes of this example, I'm assuming the table view is in there alone.
scrollView.contentSize = tableView.contentSize;
like image 78
Bonnie Avatar answered Oct 06 '22 00:10

Bonnie