tableview data source method is not getting called in navigation based application - uitableview

In my app control goes to numberOfSectionsInTableView and numberOfRowsInSection datasource methods but not to cellForRowAtIndexPath.
I am not able to find the problem,please any body give a solution for this.
Thanks in advance

Related

How can I achieve rowspan in UITableView

Please see image below, the image is currently done in HTML and CSS, I want to achieve similar result in UITableView, in some cells I want to show banner advertisement so I will to do some sort of rowspan for 3 cells, any clue how can I achieve this?
Please note the data is coming via webservice and it have scrollable pagination implemented, so making one custom cell containing group of cell ideas wont work, let me know how to achieve this, thanks.
Check this question.
In a few words - move every cell to its own section and implement methods heightForHeaderInSection and viewForHeaderInSection for your tableView

Moving code to willDisplayCell to improve UITableview scrolling

I have seen this paragraph below from the internet and followed his recommendation and moved my code to willDisplayCell. However, I don't see any performance improvement. So I did some further investigation and found out that there are some other people saying what the paragraph said is not true. Proper Use of CellForRowAtIndexPath and WillDisplayCell . I am confused which guide I should follow at this stage as most of the time I put my code in cellForRowAtIndexPath
But very important thing is still there: tableView:cellForRowAtIndexPath: method, which should be implemented in the dataSource of UITableView, called for each cell and should work fast. So you must return reused cell instance as quickly as possible.
Don’t perform data binding at this point, because there’s no cell on screen yet. For this you can use tableView:willDisplayCell:forRowAtIndexPath: method which can be implemented in the delegate of UITableView. The method called exactly before showing cell in UITableView’s bounds.
I have done some test myself as well and found that there is no significant difference between putting the code in willDisplayCell and CellForRowAtIndexPath. So I believe the argument in the ink you have provided is more true. Unless anyone found anything different?

Why isn't cellForRowAtIndexPath fired but other methods are?

numberOfSectionsInTableView and numberOfRowsInSection are both called on my table. The array I'm using has 3 items in it.
cellForRowAtIndexPath is never called. What would cause this behavior?
Might be something to do with the dimensions of your tableView. See this other answer for details. Basically, what is says is that if your tableView is too small, then the cellForRowAtIndexPath method is never called. Try making your tableView smaller, or decreasing the size of your header or footer of the tableView. If this doesn't work, try reloading the table using tableView.reloadData() on the main thread.

numberOfRowsInSection returns more than 0; cellForRowAtIndexPath still not being called

I notice this problem is very common and there are alot of posts about it but none of the solutions i tried so far worked.
So I have a delegate method that updates the datasource: NSArray * posts and reload the table view. I am positive that posts is updated before the reload call because i logged it.
It calls the numberOfRowInSection method and [posts count] returns more than 0 every time. but the cellForRowAtIndexPath is still not called.
the tableview is created from the IB and content is currently shows content and the cells before the reload. i need one of the cells content to be updated but it doesnt because cellForRowAtIndexPath is not called.
This only happens for the delegate method.
I tried making the reload call on the main thread using both gcd and perform selectorOnMainThread still no go.
Any ideas what maybe causing this problem and how to fix it?
Make sure you have UITableViewDataSource, UITableViewDelegate in your .h and connected the tableview delegate, data source and cellindentifier Cell in .xib.
have you registered your cell ?
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:#"Cell"];
Load your tableView in method
awakeFromNib
this solved my problem.

UITableView reloadData and cellForRowAtIndexPath - interruptable?

Let's assume there exists a UITableView called myTable. Let's say the following sequence of events occur --
Table is fully populated.
The data source is updated (in this case an sqlite3 db, but doesn't really matter), an NSNotifcation happens to indicate that there is new data, the main thread receives the notification and then calls [myTable reloadData].
myTable's UITableViewDataSource's numberOfSectionsInTableView gets called. Assume only 1 section.
myTable's UITableViewDataSource's tableView:numberOfRowsInSection: gets called.
Several tableView:cellForRowAtIndexPath:'s get called depending on the number of rows in the data source.
My question has to do with the interruptability of cellForRowAtIndexPath.
The question --
If a "reloadData" is called and cellForRowAtIndexPath's are getting called AND another reloadData comes in, will the cellForRowAtIndexPath's stop midstream and restart after the calls to numberOfSectionsInTableView and numberofRowsInSection?
Or will the new reloadData be queued, such that all of the cellForRowAtIndexPaths will finish BEFORE the numberOfSectionsInTableView and numberOfRowsInSection get called?
I've looked and have been unsuccessful in finding an answer to this question in docs or the net. I'm concerned that if the data store is updated while the cellForRowAtIndexPaths are "running", the numberOfSectionsInTableView can change which can result in the cellForRowAtIndexPath requesting data for a cell that's now out of range.
Any help would be greatly appreciated.
Since you should only call reloadData on the main thread and since by the time a call to reloadData is done, all of the visible cells have already been loaded, there is no problem to worry about. The second call to reloadData will be made after the 1st one is done.
I don't think it is possible to be in the middle of cellForRowAtIndexPath when reloadData is called assuming they are both called on the same (main) thread (having an async processing on background thread at cellForRowAtIndexPath seems meaningless).

Resources