Reputation: 3693
In one of my scenes I have a table view (and another view) inside of a view. Since my table view is not the outer view, I cannot use UITableViewController to handle the table view. How would I go about managing the table view?
Thanks for any help!
My current view controller for the view containing the table:
class CViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Upvotes: 1
Views: 2130
Reputation: 389
You need to implement UITableViewDelegate and UITableViewDataSource. You also need to make sure that the tableView is pointing at your Viewcontroller for the Delegate and DataSource. You can do that in Interface Builder.
class CViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// return the number of rows
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
// create your cells
}
}
Upvotes: 2
Reputation: 2830
I don't know swift, but in general if you want to manage a table view then you implement the methods for UITableViewDelegate and UITableViewDataSource.
Upvotes: 0