简体   繁体   中英

How can I inherit a UIScrollView like what the UITableView do?

I want to create a scroll view filled with grid cell of irregular size.

The UITableView , inheriting the UIScrollView , alloc cells effectively. I just want to do the same.

Of couse, it is possible to use UIScrollViewDelegate to detect scroll event. But that will hold the delegate property. I want to use the delegate property as it used to be. So I have to inherit the UIScrollView as the UITableView does.

The question is how to do that? Which method should I override to get the scroll event?

如果只想实现具有任意高度的单元格,则只需实现tableView:heightForRowAtIndexPath:即可确定表中每个单元格的高度。

You should watch the WWDC 2010 video for UIScrollView, which includes lots of information about how to lay out many views. https://developer.apple.com/videos/wwdc/2010/

You could also look at the PhotoScroller example code for how to tile many views.

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