Can we add a scroll view inside UITableViewCell?

我怕爱的太早我们不能终老 提交于 2019-12-06 09:06:24

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.

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!