UITableViewController inside UIScrollView with Horizontal Paging

送分小仙女□ 提交于 2019-12-03 14:24:50

I did something similar a few months ago, and it was like this:

  • UINavigationController
    • UIViewController with a UIScrollView
      • UIViewController with a UITableView inside (I use this because I simply hate UITablewViewController)

I followed the Apple's documentation about creating custom containers. There is a great video about that in the WWDC 2011 video's section if I am not mistaken. I can proudly say that the code is really clean and simple to understand.


Answer 1.0

The one thing is, did you managed to get proper orientation handling of the tableView, without any hack, or you don't use it?

No, in this case I didn't, but I am sure I would have been able to do it without any problem. You see, most of the problems come when you just [self.view addSubView:newViewController.view];. You just add the UIView, all the logic of the rotation is handled by the newViewController and not in the controller where the UIView will be.

The other thing is, if i'm gonna try to implement, say, GridView or something like that, for iPad, orientation handling and animations become very ugly.

I implemented this in another project and it was quite easy to implement once you understand what's going on:

  1. I used a UIViewController with a UITableView so I could get all the goodies from the dequeueReusableCellWithIdentifier:, creation of section's titles, table's headers and footers, etc. I just figure that no matter what I would do with a UIScrollView a UITableView is always going to be more optimized. As the UITableViewCell's I just used an holder with 3 squares, each one being a picture. (my application was a showcase of pictures)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!