Re: Design for custom tableviewcell button action
Re: Design for custom tableviewcell button action
- Subject: Re: Design for custom tableviewcell button action
- From: WT <email@hidden>
- Date: Thu, 25 Jun 2009 10:54:35 +0200
On Jun 25, 2009, at 10:26 AM, Alexander Spohr wrote:
Am 25.06.2009 um 10:16 schrieb WT:
I had exactly the same problem and here's how I solved it.
Why didn’t you put the cell into the controllers nib?
Make an outlet in your controller to reach the cell and just return
it when you need it?
The second nib seems to much work. And you get a speed bump by
loading it.
- (UITableViewCell*) tableView: (UITableView*) table_view
cellForRowAtIndexPath: (NSIndexPath*) index_path
{
static NSString* cellID = @"cellID";
CustomCell* cell = (CustomCell*) [table_view
dequeueReusableCellWithIdentifier: cellID];
if (cell == nil)
{
cell = customCellOutlet;
// other one-time cell configuration stuff here
}
// per-cell configuration stuff here
}
Because -tableView:cellForRowAtIndexPath: needs to return a different
cell object for each visible row. Your code above returns always the
same object, the one table view cell archived in the nib, which means
that changing the data in one cell would change the data in all
visible cells, and all visible cells would have the same data all the
time.
Wagner
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden