ios - UiTbleview Cell Overlapping when scroll more time -
i using uitableview
displaying different data in view. using uitableviewcell
created code in .m file. total 9 different kind of cell 0 different identifiers , heights cell. when same cell 2 different heights in table start overlapping each other.
here putting code height of cell method.
- (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { if(indexpath.row ==0) { return 120.0; } else{ //for action user follow if(condition) { //checking if follow shared or not if() { //checking number of counts if() { if() { if() { return 340.0+(artemp1.count*50.0); } else { return 157.0+(artemp1.count*50.0); } } else { if() { return 340.0+200; } else { return 157.0+200; } } } else { if( ) { return 340.0f; } else{ return 157.0f; } } } else { if(artemp1.count>0) { if(artemp1.count <4) { if() { height=height+150; } return height+(artemp1.count*50.0); } else { if( ) { height= height; } return height; } } else { if() { height= height+40; } return height; } } } else if () { if(artemp1.count>0) { if(artemp1.count <4) { return 160.0+(artemp1.count*50.0); } else { return 160.0+200; } } else { return 150.0f; } } //for action add new reciepe else if () { if(artemp1.count>0) { if(artemp1.count <4) { return 420.0+(artemp1.count*50.0); } else { return 420.0+200; } } else { return 400.0f; } } else if () { if(artemp1.count>0) { if(artemp1.count <4) { return 350.0+(artemp1.count*50.0); } else { return 350.0+200; } } else { return 350.0f; } } //for action added new page else if () { if(artemp1.count>0) { if(artemp1.count <4) { return 350.0+(artemp1.count*50.0); } else { return 350.0+200; } } else { return 350.0f; } } else if () { if(artemp1.count>0) { if(artemp1.count <4) { return 170.0+(artemp1.count*50.0); } else { return 150.0+200; } } else { return 150.0f; } } //for action add photo else if () { if(artemp1.count>0) { if(artemp1.count <4) { return 350.0+(artemp1.count*50.0); } else { return 350.0+200; } } else { return 350.0f; } } } return 0.0f; }
cell row code
nsstring *cellidentifier = @"a"; uitableviewcell *a = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (a == nil) { //follow cell initializing = [[[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease]; a.selectionstyle = uitableviewcellselectionstylenone; a.tag=a; //create cell method [self acreatecell:a atindexpath:indexpath]; } // set cell method [self asetcell:a atindexpath:indexpath]; [a setclipstobounds:yes]; return a;
try this
first register cell class tableview
- (void)viewdidload{ /*if using class */ [self.tableview registerclass:[uitableviewcell class] forcellreuseidentifier:@"cellidentifire"]; /* if using nib */ // load nib file cell uinib *nib = [uinib nibwithnibname:@"customnibcell" bundle:nil]; // register nib cell table [self.tableview registernib:nib forcellwithreuseidentifier:@"cellidentifire"]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{ uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cellidentifire" forindexpath:indexpath]; /* write code cell.title= @"hello"; */ return cell; }
Comments
Post a Comment