i have grouped-style uitableview intended show fixed number of sections, each of 1 having in turn fixed set of cells, settings app. of cells custom , different between them: of them have textfield, have switch, button. have uitableviewcellstyledefault
cells.
custom cells loaded nib
files, , i've defined strong
property each cell in whole table view. cellforrowatindexpath:
method looks this:
- (uitableviewcell *)tableview:(uitableview *)tv cellforrowatindexpath:(nsindexpath *)indexpath { uitableviewcell *cell = [tv dequeuereusablecellwithidentifier:@"cell"]; if (cell == nil) { if (indexpath.section == 0) { if (indexpath.row == 2) { nsarray* views = [[nsbundle mainbundle] loadnibnamed:@"typeacell" owner:nil options:nil]; (uiview *view in views) { if ([view iskindofclass:[uitableviewcell class]]) { cell = (typeacell *)view; } } // set property self.typearow = cell; } else { nsarray* views = [[nsbundle mainbundle] loadnibnamed:@"typebcell" owner:nil options:nil]; (uiview *view in views) { if ([view iskindofclass:[uitableviewcell class]]) { cell = (typebcell *)view; } } // set properties if (indexpath.row == 0) { self.typebrow0 = cell; } else { self.typebrow1 = cell; } } } else { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:@"cell"]; // set property self.defaultcell = cell; } } return cell; }
for custom cells, i've set reuse identifier "cell" in nib
files. correct way proceed when know beforehand set of cells table represents example form or menu, settings app? reuse identifier same cells, or should each different cell have unique identifier?
thanks!
Comments
Post a Comment