Programmatically set UITableView datasource and delegate
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.
精彩评论