iphone - Custom Cell from Nib UITableView -
I am trying different ways with no success of changing the following code ...
< P> I have a nib file which works properly if I set all the cells on it but I only need one of the switch statements for custom STATE Nib file. Any ideas? - (UITableViewCell *) TableView: (UITableView *) table view cellheroutoutpath: (NSIndexPath *) Index pathway {NSUntengar line = [index line]; NSInteger section = [index section]; UITableViewCell * cell; Switch (section) {case 0: cell = [tableView dequeueReusableCellWithIdentifier: @ "any-cell"]; Cell = [[[UITableViewCell alloc] initWithFrame: CGRectZero reuseIdentifier: @ "any cell"] autorelease]; Cell.text = [Shows ObjectsOutIndex: Line]; break; Case 1: Cell = [Tableview Décures reusable cell death identifier: @ "any cell"]; Cell = [[[UITableViewCell alloc] initWithFrame: CGRectZero reuseIdentifier: @ "any cell"] autorelease]; Cell.text = [Shows ObjectsOutIndex: Line]; break; Default: cell = [Tableview DeWewer re-qualified CellWithIdentifier: @ "any cell"]; Cell = [[[UITableViewCell alloc] initWithFrame: CGRectZero reuseIdentifier: @ "any cell"] autorelease]; Cell.text = [Shows ObjectsOutIndex: Line]; break; } Return cell; }
You will need to do two things:
- Make a separate cell identifier for the cell that you want to use with nibb, using "any cell" can result in your cell being reused for different lines.
- Instead of UITableViewCell's
initWithFrame: reuseIdentifier:
method, you need to start the cell from your nibb. Check the section on using Nibs. In addition, although it is not technically necessary, theinitWithFrame: reuseIdentifier:
method of UITableViewCell is deprecated in favor ofInitWithStyle: ReuseIdentifier:
.
Comments
Post a Comment