UITableView resizing rows problem - iphone

Hope to get solution to this problem. I have been stuck on it since a long time now.
I have a a tableView which has custom labels drawn upon the cell using CGRect. I receive the data from a web service in arrays. Initially i display a line of data on the cells. When the user selects a cell, I call reloadsRowAtIndexPath to increase the height of selected row. In the process, cellForRowAtIndexPath gets called again. I keep track of this by a flag, and when cellForRowAtIndexPath gets called again, I display the two more lines of data from arrays, on the cell.
What i am getting is all overlapping data on one other. I tried to remove already placed labels in didSelectRowAtIndexPath, but to no avail.
Please help me on this
Thanks in advance.

In your cellForRowAtIndexPath method, when the selected row height needs to increase, do you create a new UITableViewCell object or change an already allocated one?
Please can you post your cellForRowAtIndexPath method code to help track this down?

Related

iPad UITableView flickering issue

I have a UITableView that contain about 20 rows in the iPad's viewport. I have a interval timer that will call UITableView's reloadData regularly(post it to UI thread).
Now when I scroll through the UITableView with medium speed (not so fast), that UITableView will refresh with flickering effect.
I have to write a function to manually update the UITableViewCell label by looping through all the items in the array (this array keep all the items that show on UITableView). I will execute this function when timer is running instead of calling reloadData (as I mentioned above). Then the flickering issue is gone.
I believe that reloadData should be better than looping through all the data because reloadData will only refresh the current showing Cells instead of all the rows, but I couldn't figure out why the flickering happens. Anyone know why?
One thing I have to mention is I did use the CellIdentifier correctly to reuse the cell and only create the cell when the retrieved cell is null.
Moreover, I do not have this issue in iPhone and I believe that it is because iPhone has lesser row compare to iPad.
Anyone can give some explanation about this issue?
I had the same problem with flickering when using reloadData. I solved it by using indexPathsForVisibleRows and cellForRowAtIndexPath: to only update the visible cells. Performance is good since I don't have to iterate over the whole data set, but only a limited number of visible cells.
reloadData causes the tableview to recreate the visible cells on screen which can result in a flickering since the cells get destroyed. There are better ways to reload the tableview. Are you using Core Data? If so the NSFetchedResultsController and it's delegate are a great way to update a tableview since it listens to changes in the underlying datasource and only updates the appropriate cells.

CellForRowAtIndexPath returning the wrong cell

I am running into an issue where cellForRowAtIndexPath is returning the wrong cell and therefore, it is seguing and performing other actions on the wrong cell.
I have built custom cells that are quite big because I am fitting some UIImageViews (+text +buttons), so a cell takes up the entire screen. When you scroll down and two cells are on the screen at the same time, if you tap on the top one, it segues to the content of the bottom one (same for button actions inside the cell).
I thought this might be specific to IB, so I rebuilt everything in code, but am still having the same behavior.
Is there any way to fix this and maintain the correct indexPaths?
I think you have your perspective wrong. cellForRowAtIndexPath doesn't return wrong cells. It should just return a fresh cell, which may have been recycled if you're using dequeueReusableCellWithIdentifier or similar. In which case, dequeueReusableCellWithIdentifier will return any old cell which may have just scrolled off the top. It's your job to take the fresh cell (which may be a new cell or a recycled one) and stuff the correct values in it, inside cellForRowAtIndexPath. Then the cell it returns will be the "correct" one because you've just written all the correct values to it. So I would look at your implementation of cellForRowAtIndexPath to make sure that correct values for the index path that you're passed are stuffed into the cell that cellForRowAtIndexPath returns.

TableView reloaddata

I wanted to know something that I found regarding tableviews. I have UITableView whose items are being generated dynamically, means rows. Now whenever I scroll UITableView to end and stretch the scroll up and release it (u know iPhone style), my cellForRowAtIndexPath gets called. I noticed this because I had my NSLog there. Does this happen normally?
Actually, thing is I am also lazy loading image for UIImageView in each row inside tis method, so I think because of this my lazy loader is also getting called and I don't want this.
This is a normal behaviour. The method cellForRowAtIndexPath is getting called for the new rows which are now visible. This makes the whole table more responsive, because it does not have to render all the rows at same time.

iphone tableview scrolling issue

I have a tableview with imageviews and textviews in each cell. When my view is loaded one of the textviews is invisible. But when I start scrolling the textview appears, so that my view looks as it is supposed to look. Does anyone know why this is happening?
P.S. I have read about reusing cells when scrolling so I have been very careful to construct my cells correctly.
Without code, no one can give you a exact answer. But for a guess....
Is your data is getting populated after your table call cellForRowAtIndexPath? When the cell populates the first time, no data, so the cell is in it's unformatted state. By the time you can interact with the table and scroll it off and on screen (which calls cellForRowAtIndexPath again), the data has been populated and so the cell looks as expected.
You can test this by putting a breakpoint in your cellForRowAtIndexPath method and check to see if your data objects are initialized or still set to nil.

iPhone: some UITableView's cells appears blank in edit

I use tableView with custom cells and for cell drawing I use drawRect: method for scrolling performance. In edit mode when I move cells move and down sometimes some cells appear blank. And during scrolling also random cells start appear blank.Please look attached images. Can someone help to understand problem?
if you are using dequeueReusableCellForIdentifier then try removing that.
I mean to say alloc a new cell every time.
I am suggesting above based on assumption that your cell contains some heavy data which takes time in drawing. In this case if you reuse cell then it will take cell that goes out of visible screen and will paint draw new data in it.
If this doesn't help then please post some code showing how you are creating custom cell.