3

I have too many columns in my table and too much data too. For that reason I need to scroll my UITableView both vertically and horizontally. Is there a direct way to do so or I need to go through sources like Easy tables?

halfer
  • 19,824
  • 17
  • 99
  • 186
Nitish
  • 13,845
  • 28
  • 135
  • 263
  • 1
    A quick solution to ur problem would be to have a uitableview inside a uiscrollview. Dont change the height of the contentsize just change the width. that way you will be able to scroll horizontally\ – Robin Feb 06 '12 at 06:56
  • 1
    One solution as @Robin says and other you can refer this tutorial http://www.raywenderlich.com/4723/how-to-make-an-interface-with-horizontal-tables-like-the-pulse-news-app-part-2 it has given source code to which is easy to understand and customizable according to requirement. – Janak Nirmal Feb 06 '12 at 07:02

3 Answers3

6

You can 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.

Mudit Bajpai
  • 3,010
  • 19
  • 34
1

I have a similar situation: a lot of columns and rows, the tableView needs to be horizontally scrollable. My solution is like that: predefine a column header with width same as the desired tableView, say 537

top view (320 x 455)
 + scroll view (320x455), content size = (537x455)
   + view as a container (537 x 455)
     + column header (0, 0, 537, 44)
     + tableView (0, 44, 537, 455-44)

Create a function to compute these numbers and reattach the frames to each object after tableview reload, call this function

monkeyinsight
  • 4,719
  • 1
  • 20
  • 28
0

Here is a trick to do both vertical and horizontal scrolling with a UITableView.

Playing with width and contentsize to make it work: https://stackoverflow.com/a/41230797/860488

Community
  • 1
  • 1
Morten Holmgaard
  • 7,484
  • 8
  • 63
  • 85