uitableview - Multiple table view section: first section with static cell and second section with dynamic number of cell -
as title says, create table view 2 sections. first sec contains 1 cell textbox. sec section should filled dynamically content of array.
i wrote code:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { if (indexpath.section == 1) { static nsstring *simpletableidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:simpletableidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:simpletableidentifier]; } player *player = [self.playercontroller getplayeratpositon:indexpath.row]; cell.textlabel.text = [nsstring stringwithformat:@"%@", player.persistentdata.name]; homecoming cell; } else { // ??? } }
but have write else
codeblock? cell filld textbox not overwrite?
i found out, can't add together elements dynamically. when want add, example, 3 players, have set rows-value three. otherwise app crash. there way dynamically?
you have 2 types of cell 1 has textfield, , sec has player info. should create different cell identifier each kind of cell.
static nsstring *cellidentifier1 = @"cell1"; static nsstring *cellidentifier2 = @"cell2"; if(indexpath.section == 0) { // create , homecoming cell cellidentifier1 } else { // create , homecoming cell cellidentifier2 }
one more thing while allocationg uitableviewcell don't forget add together autorelease @ end ... hope help you....
uitableview ios7
No comments:
Post a Comment