Luda
Luda

Reputation: 7078

UITableView in UIView

I want to create a UITableView in UIView class. Can I? The UITable is nested in the UIView, so I figured, I should put the code of the the table in my custom UIView class, but on the other hand, usually the UIViewController is responsible for the table delegates. So what is best?

Upvotes: 1

Views: 152

Answers (1)

bbarnhart
bbarnhart

Reputation: 6710

UITableView has a data source and a delegate which need to be implemented. These could be implemented separately in different objects or they could be implemented in the same object.

Many times, the UIViewController is used as the data source and delegate object but it's not required. Since you're adding the UITableView to a custom UIView it makes sense create a custom object to handle the data source and delegate.

It's fine to add a UITableView to a custom UIView which is not the UIViewController's view.

Upvotes: 1

Related Questions