Reputation: 5408
I am trying to configure a page to look something as follows - where I have a standard view controller with a table view inside of it.
I have my prototype cell denied, so I can configure these in code and add the relevant images.
However, I am trying to set the code base up to do this (i.e.) implement the required table view methods but am getting a number of errors;
Is this occurring because this only apples when you have a UITableView and not a Table in a normal view controller? If so, how do I manage my dynamic table in the code?
Thanks for your time
Upvotes: 0
Views: 363
Reputation: 23078
When using a UITableView
in a viewcontroller (not in an UITableViewController
) as you are doing it, your custom viewcontroller has to implement the UITableViewDataSource
and the UITableViewDelegate
protocols.
At least the following required functions:
class MyViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
...
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
}
}
Since your class is not derived from UITableViewController
it does not override
these functions, so remove the override
directive.
Upvotes: 2