UITableView method cellForRowAtIndexPath not called
Got it!
Had the same problem - I also have added a tableview into a uiviewcontroller and it also not worked, but I know the problem now.
If you add the tableview on interface builder AND click after that "Add Missing Constraints", it'll add constraints that can't work together.
At my position I had the tableview on my whole uiview and after click on "Add Missing Constraints", it will add this here:
And now if you delete one of the Trailing or Leading Alignments, it will work - cellforrowatindexPath will get called! Don't know why it is like that, but it will work.
Hope I can help you.
Check if you have these lines:
tableView.delegate = self
tableView.dataSource = self
If dataSource = self
is not implemented it could be a reason of not called cellForRowAt indexPath
method
You need to implement this or cellForRowAtIndexPath
will never be called:
override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
// Return the count of the number of rows in the table
return 5
}
The 5
is just an example of course. You would return the count of the number of elements in your array.