开发者

Programmatically set UITableView datasource and delegate

开发者 https://www.devze.com 2022-12-09 23:47 出处:网络
I have a UIScrollView that contains multiple UITableViews horizontally - all of which are created programmatically depending on the user\'s action.

I have a UIScrollView that contains multiple UITableViews horizontally - all of which are created programmatically depending on the user's action.

Say I have 4 UITableViews, how do I set the datasource and delegate for each one programmatically? I understand there are tableViewX.dataSource and tableViewY.delegate methods; and I assume I set them to an NSObject that obeys the UITableViewDataSource and UITableViewDelegate protocols, but everything I try seems to do nothing to my UITableViews.

I created the NSObject from a template of the UITableViewController and changed it开发者_如何学运维s class type.


Ah. Figured it out. Needed to allocate and initiate the NSObject first, before setting it as the delegate and dataSource.

0

精彩评论

暂无评论...
验证码 换一张
取 消