It does not really have anything to do with the dequeueing of cells but the data you are displaying in the cellForRowAtIndexPath. Every time a cell is going to be displayed, this method is called I assume you are changing the language of the cell's text on button click. But every time the cell is redrawn you are redisplaying the english text.
One way to "retain" the cell's state would be to create an array for the languages being used on each cell and based on the array's value for a particular row, populate the cell's text. You will just have to maintain the state of the cell in the array.
It does not really have anything to do with the dequeueing of cells but the data you are displaying in the cellForRowAtIndexPath. Every time a cell is going to be displayed, this method is called. I assume you are changing the language of the cell's text on button click.
But every time the cell is redrawn you are redisplaying the english text. One way to "retain" the cell's state would be to create an array for the languages being used on each cell and based on the array's value for a particular row, populate the cell's text. You will just have to maintain the state of the cell in the array.
You will just have to maintain the state of the cell in the array....No you don't look at my post – Daniel Jul 20 '09 at 17:53 Actually I came up with this solution on my own. It works quite well (though it does seem to make scrolling a little jerky it seems). Might try another strategy as my tables will rarely be longer than 15-20 cells.
– Bill Jul 21 '09 at 13:18.
OK I had this problem too, took me awihle but I figure it out, the cell queue is they key here, when you are trying to get your cell back your are using this NSIndexPath *thisCellPath = NSIndexPath indexPathForRow:sender tag inSection:0; dialogue_cell *thisCell = (dialogue_cell *)self. DialogueTable cellForRowAtIndexPath:thisCellPath; When the cell is off the view, the table view unloads this cell and instead you get a cell thats in the original state (or prolly nil) when you call this because its n ot longer part of the table view until the cells come back into the view screen. What you have to do is since you a re enqueuing your cells, I am going to assume you are doing this correctly and you are giving a different name to each cell, instead of doing what you did above you must get your cell like so cell=tableView dequeueReusableCellWithIdentifier:dialogueCellIdentifier; This will give you your cell with the state it was in when the user modified it...Hope this helps!
As for your second question, you can just set the target to be the cell instead of the view controller, this will call that action inside your custom cells class..
Thanks for the help - actually I made up my own scheme similar to what lostInTransit said above and it works great. Nothing quite like that feeling of solving a problem! – Bill Jul 21 '09 at 13:17.
The table is put together using custom cells (with IB xib) and data from an xml file. In the custom cell there are two buttons - and when the cell is created the button action is added as an addTarget to self (the viewcontroller) which then goes to an action. The viewcontroller button action method gets the row of the button pressed in the table and then changes the cell's text and the button's title.
But of course when I scroll that particular cell out of view and back into view it's been reset to the beginning state. I assume this has to do with cell dequeueing etc. Any ideas? Custom cell: has outlets to buttons and textlabel.
Is there a way to make the cell retain what is in the label and button name even though it's scrolled offscreen? Is there a way to set the label and button name within the cell custom class instead of sending the button action to the viewcontroller that the table is in?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.