0

I'm developing an ios application which has a table view. when there is a long value in table cell, table column width size should be increase. I've develop a custom UI for this requirement as following images.

Image 1: showing the user interface in normal viewport size

I have change the content size using following code, but it isn't increase the table body size. you can see it in following image.

self.resultTableView.contentSize.width = self.cellWidth!

When Try to scroll, it will not expand the table view

Finally everything become invisible

You can see the first image its appear as it is and when there is more indexes (columns) and user try to scroll horizontally towards right(as shown in second image), table view will not expand more than the viewport size.

How can I do table view fit to the scroll size?

and finally everything become invisible.

feel free to ask anything if you dont clear enough the quection.

Community
  • 1
  • 1
Dehan Wjiesekara
  • 3,152
  • 3
  • 32
  • 46

1 Answers1

2

I guess what you have to do is dynamically calculate the desired width and then set the tableView width (for example with a tableView.widtAnchor) to exactly this width.

For a table that scrolls into both dimensions, this could also be helpful: http://www.brightec.co.uk/ideas/uicollectionview-using-horizontal-and-vertical-scrolling-sticky-rows-and-columns

choli
  • 312
  • 1
  • 4
  • 14
  • Hi choli. I have edited my quection, can you go through it. – Dehan Wjiesekara Apr 20 '16 at 04:14
  • The way I see it, you have to calculate the width of your "title cell" and then set the frame width of your tableView accordingly on a scrollView, and also set the scrollView's contentView to that width. If you use autoLayout, then just set the tableView on all 4 sides to the scrollViews contentView sides, and you just need to increase the tableView width. – choli Apr 20 '16 at 06:01
  • So first, I meant to say that you have to adjust the contentSize of the scrollView, there is no contentView on the scrollView. But also be aware, that, even if it works, a tableView should not be embedded in a scrollView, see: http://stackoverflow.com/a/21857041/1105464 – choli Apr 20 '16 at 06:23