json - How to Set a array data First value in Tableview First Section and remaining array data value in Second Section of tableview in iOS? -
i newbie in ios , know question asked many times not getting solution.i made application tableview here tableview code containing 2 section , want fill section json data.i made 2 customcell. display not able fill json parsing data.
my code is.
-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { if (indexpath.section == 0) { static nsstring *cellidentifierone=@"cellone"; custumcell *cellone =[tableview dequeuereusablecellwithidentifier:cellidentifierone]; if (cellone == nil) { nsarray *nibone=[[nsbundle mainbundle]loadnibnamed:@"custumcell" owner:self options:nil]; cellone=[nibone objectatindex:0]; cellone.userinteractionenabled=no; } { [cellone.spinner startanimating]; nsdictionary *dict = [self.imagearray objectatindex:indexpath.section]; nsstring *img2=[dict valueforkey:@"front_image"]; [cellone.storeimage sd_setimagewithurl:[nsurl urlwithstring:[img2 stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]] placeholderimage:[uiimage imagenamed:@"setting.png"] options:sdwebimagehighpriority completed:^(uiimage *image, nserror *error, sdimagecachetype cachetype, nsurl *imageurl) { [cellone.spinner stopanimating]; cellone.spinner.hideswhenstopped=yes; }]; } homecoming cellone; } else { static nsstring *cellidentifiertwo=@"celltwo"; tablecell *celltwo=[tableview dequeuereusablecellwithidentifier:cellidentifiertwo]; if (celltwo == nil) { nsarray *nibtwo=[[nsbundle mainbundle]loadnibnamed:@"tablecell" owner:self options:nil]; celltwo=[nibtwo objectatindex:0]; celltwo.userinteractionenabled=no; } homecoming celltwo; } homecoming nil; }
and here tableview section 2 , code numberofrow is
-(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { if (section == 0) { homecoming 1; nslog(@"images %@",self.imagearray); } else { homecoming self.imagearray.count - 1; } }
when there no info shows want, not able fill info please provide me solution.
@ashishgabani
look @ below code, understand requirement
i have taken array, contains values this
nsmutablearray *imagearray = [[nsmutablearray alloc]initwithobjects:@"1",@"2",@"3",nil];
next tableview methods:
-(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { if (section==0) homecoming 1; homecoming imagearray.count-1; } - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { homecoming 2; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{ static nsstring *simpletableidentifier = @"simple"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:simpletableidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:simpletableidentifier]; } if(indexpath.section==0) { cell.textlabel.text = [imagearray objectatindex:indexpath.row]; } else { cell.textlabel.text = [imagearray objectatindex:indexpath.row+1]; } homecoming cell; }
just comment existing code , re-create code , paste xcode viewcontroller , run simulator, think reached requirement .
ios json uitableview
No comments:
Post a Comment