I have a tabbar view that is connected to some items.
I want that one of these items contains a TableView
, but I don't want to use a TableViewController
because I want to put something else in the head of the page.
My ViewController
implements the 2 protocols UITableViewDataSource
and UITableViewDelegate
and contains the following functions:
func tableView(_ tableView: UITableView, numberOfRowsInSection
section: Int) ->
Int {
// Return the number of rows in the section.
return annunci.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath:
IndexPath) ->
UITableViewCell {
let cellIdentifier = "Cell"
let cell = tableView.dequeueReusableCell(withIdentifier:
cellIdentifier, for: indexPath)
// Configure the cell...
cell.textLabel?.text = annunci[indexPath.row]
return cell }
Then, from the storyboard I added a prototype cell with identifier "Cell" and linked the tableView
to the viewController
as DataSource and Delegate.
When I run the app it is ok, but when I select the item that contains the table view the app throws this exception:
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[UIViewController
tableView:numberOfRowsInSection:
unrecognized selector sent to instance 0x101c29370'
How can I put something on the top of the page and then the tableView or how can i solve this problem?
I am using Swift 3 and Xcode 8.2.1