Can we add a scroll view inside UITableViewCell?
Solution 1
Of course you can add scrollView in tableView.
UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 100)];
[cell.contentView addSubview:scrollView];
Now you can set properties for scroll view accordingly.
Solution 2
Yes it is definitively possible and reasonable.
Here is an excellent tutorial by Felipe Laso that explains it step by step:
How To Make An Interface With Horizontal Tables Like The Pulse News App: Part 1
How To Make An Interface With Horizontal Tables Like The Pulse News App: Part 2
BTW, the approach described in that tutorial is way more efficient than adding a UIScrollview to each cell.
thatguy
Updated on June 04, 2022Comments
-
thatguy almost 2 years
I have requirement where I have to show some images which are differentiated according to Groups they belong to. I have used a table view to view images listed under groups. User has to scroll horizontally to view more images in a particular group. Can we add a scroll view to tableview row to allow user to scroll list of images horizontally? I searched a bit, some comments say its not allowed in apple's HIG some comments say You can add a UIScrollView to a UITableViewCell and as long as you set the contentSize property of the UIScrollView correctly then the UIScrollView will scroll correctly in the horizontal axis
May I get any confirmation on this ?? Or any alternative approach to achieve horizontal and vertical scrolling for different data without using tableview
-
JonB over 12 yearsThe HIG was made to be broken.
-
Joe Masilotti over 11 yearsDo you have any sources proving that nested
UITableView
s are more efficient thanUIScrollView
s? I dont' see anything in the links you provided. -
Felix over 11 yearsUITableView is a UIScrollView subclass that is more efficient because it can reuse cells. In a scroll view you would have lots of sub views that all consume memory at the same time.