1

I need a tableviewcontroller that scrolls horizontally instead of vertically.

Is there one available? Because I have to use a scrollview now which might get memory hungry after a while!

TheLearner
  • 19,387
  • 35
  • 95
  • 163

6 Answers6

4

Try implementing this in a UIScrollView, and reuse your cells.

Alex1987
  • 9,397
  • 14
  • 70
  • 92
1

We have used UIScrollView for each cell and we scroll them together when either of them is scrolled. Our app has loads of data in the tableview and we are doing fine. You can try this approach.

Hetal Vora
  • 3,341
  • 2
  • 28
  • 53
1

I would make my own horizontal table view that inherits from UIScrollView. Implementing your own dequeueReusableCellWithIdentifier: isn't very hard.

Erik B
  • 40,889
  • 25
  • 119
  • 135
0

What about using the standard one, then rotating the contents of each of the cells by 90 degrees?

It would have the same effect for the end user.

Twelve47
  • 3,924
  • 3
  • 22
  • 29
  • Didn't know you could even do that. Do you perhaps have an example? – TheLearner Apr 11 '11 at 14:41
  • I don't have an example of that specifically, all you need to do is create a custom table view (eg http://stackoverflow.com/questions/3730750/custom-uitableviewcell-subview-layout). Then rotate the contents with something like view.transform = CGAffineTransformMakeRotation(90/180*M_PI); – Twelve47 Apr 11 '11 at 14:45
0

You could rotate your UITableView 90 degrees.

james
  • 26,141
  • 19
  • 95
  • 113
0

Yes most definitely this is possible. It is possible to do so.

STEP-1:

You just have to put your tableView under a UIScrollView in your Interface Builder or by coding as per your liking (i.e. as a subview of UIScrollView)

Using coding you can do that as

 [scroll addSubView:tableView];

STEP-2:

Then you need to make the width of tableView more than size of the View. So tableView Width is more than 320 (say it is 600)

[tableView setFrame:CGRectMake(0,0,600,460)];

STEP-3:

Then you just have to set the UIScrollView's ContentSize as CGSize(600,460) like

scroll.ContentSize = CGSize(600,420);

Now just build and run and You are done.

Hope this helps you. :)

If you have any doubts then please leave a comment here.

Remember: In any case you need to re-use your tableViewCells as otherwise it would leak memory.

EDIT:

You can refer the basic logic here for rotating your tableView by 90 degrees, though it is about UIImageView rotation by 90 degrees but I think this will help you.

How to programmatically rotate image by 90 Degrees in iPhone?

Community
  • 1
  • 1
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
  • I want each entire cell to move horizontally across the screen followed by the next one etc. so i don't want to scroll the length of a cell. so it will behave exactly like a tableview rotated 90 degrees – TheLearner Apr 11 '11 at 16:12
  • @TheLearner: Check my EDIT in my answer you will surely be helped by that. – Parth Bhatt Apr 11 '11 at 17:26