Reputation: 161
I'm using UITableViewController static cells and added UILabel and text box to it. I even added constraints. But when I run the program the cells are empty.
Here are my screenshots:
I Just found out
override func viewWillAppear(animated: Bool) {
self.navigationController?.setToolbarHidden(false, animated: true)
}
override func viewWillDisappear(animated: Bool) {
self.navigationController?.setToolbarHidden(true, animated: true)
}
above code make it disapear
Upvotes: 3
Views: 5504
Reputation: 4428
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 3
}
Upvotes: 0
Reputation: 12343
In Swift 2, tested the below fix for the question
'Comment-out' the below auto-generated/boiler plate code that comes along when you subclass UITableViewController (as you are using static cells, they may not be used)
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 0
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 0
}
Upvotes: 11
Reputation: 161
After i updated the following 2 functions return
it worked again.
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 15
}
Upvotes: 2
Reputation: 1739
If you are using static cell with custom layout as you are here, the class for the tableview should not be your custom tableviewcontroller class. Try and set your tableview and cell as the dumps below. If you, on the other hand, wants to fill the cell content dynamically, you need to make a class for the custom cell and also handle the filling of the cell in cellForRowAtIndexPath and also use dynamic prototype cells. Apple has some good explanations here and here
Upvotes: 1
Reputation: 1673
It seems that you haven't defined data source and delegate This might help you. https://guides.codepath.com/ios/Table-View-Guide
Upvotes: 0
Reputation: 6018
Maybe you forget to set Custom Class
for your TableViewController
?
Try this:
TableViewController
.Show the identity inspector
(3rd icon in right panel).Class
to your MyCustomTableViewController
class (if this class doesn't exist, create it).Upvotes: 2