简体   繁体   中英

Can we add a scroll view inside UITableViewCell?

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

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.

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.

Sure, this is possible. A UIScrollView inside a UITableCellView will work fine - the HIG says no, probably because it'll be hard to use. The user would have to accuratley scroll either up/down, or left/right and it might be annoying. Shouldn't take long to knock together a quick test.

I have an app with 2 scrollviews - one that allows horizontal scroll, and then inside that another scrollview which allows vertical scroll. The idea is that the user can flick up/down a page, then also flick left/right across pages.

It's not that nice to use, but it's what my client wanted ;)

To make a UIScrollView only respond to horizontal or vertical scroll is all about setting the correct contentSize. Hope this is some help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM