开发者

Horizontal scroll in UITableView (Dynamic number of columns)

开发者 https://www.devze.com 2023-03-18 16:15 出处:网络
I\'ve the next requirement. I can receive a list of NSDictionary with an undefined number of fields. For example:

I've the next requirement.

I can receive a list of NSDictionary with an undefined number of fields. For example:

In one request we could receive a list of

row num="25-2010" fecha="11/07/2010 19:17:14" total="227066"
row num="26-2011" fecha="11/07/2010 19:18:14" total="227066"
row num="27-2011" fecha="11/07/2010 19:19:14" total="227066"

And in other the next request:

 row num="21" jes="2010"
 row num="22" jes="2010"
 row num="23" jes="2011"
 row num="24" jes="2011"

etc.

the number of fields in the row in unlimited.

I want to create a dynamic UITableViewController to show the content, calculate the number of columns is easy, just getting the keys from the NSDictionary.

But, sometimes the number of columns require more weight than the suppo开发者_StackOverflowrted for the table.

Anybody knows if it's posible to enable an horizontal scrolling, to be able to allow to the user to scroll vertical (to see all the rows) and horizontal (to see all the columns available) ?

I tried to include an UIScrollView in the IB of the cell but doesn't works. And tried to include an UIScrollView in the IB of the View ... with the same result (following the explained in this other stov question)

Any idea or suggestion?

Thanks,

Ivan


In one of my apps I implemented this using gestures to swipe left and right, then I animate the table view off screen to the left (or right) while also animating in a new tableview to take it's place. The effect is that you can swipe and the next column slides in.


Finally, I work it out following the example shared by progrmr

Adding to the table view two gesture recognizers.

UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(paginateLeft:)];
swipe.direction = (UISwipeGestureRecognizerDirectionLeft);
[tableView addGestureRecognizer:swipe];
[swipe release];    

swipe = nil;
swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(paginateRight:)];
swipe.direction = (UISwipeGestureRecognizerDirectionRight);
[tableView addGestureRecognizer:swipe];
[swipe release];    

Additionally, I include an UIPageControl synchronized with the swipe pagination, if not the user probably doesn't have the perception that there are more available information.

Thanks!

0

精彩评论

暂无评论...
验证码 换一张
取 消