ios - how to load Different Array when table view Section Button Pressed? -
i newbie in ios development developing magazine application. in have used tableview contains 2 section , each section has preview
button shown in below image. show different images when preview
button pressed. image array parsed json. here images in array (this array contains array of images). first section wrote code like
nsdictionary *dict=[self.imagesa objectatindex:0];
but second section 2 cell there uses same custom cell. confused how show second object array when tableview's second section preview
button pressed , same way load third image array when second section's second cell preview
button pressed. if make different xibs each button in future if new cell added not work. please give me solution here web services link webservice link
i show first -demopage: array first cell , second -demopage: second , upto last cell of table view. how possible please give me solution.
here preview button code
uibutton *preview = [uibutton buttonwithtype:uibuttontyperoundedrect]; preview.frame = cgrectmake(112,95, 89, 25); preview.backgroundcolor=[uicolor colorwithred:229.0/256.0 green:229.0/256.0 blue:229.0/256.0 alpha:1.0f]; [preview settitlecolor:[uicolor blackcolor] forstate:uicontrolstatenormal]; [preview settitlecolor:[uicolor colorwithred:229.0/256.0 green:229.0/256.0 blue:229.0/256.0 alpha:1.0] forstate:uicontrolstatehighlighted]; [preview settitle:@"preview" forstate:uicontrolstatenormal]; [preview.titlelabel setfont:[uifont fontwithname:@"robotocondensed-bold" size:14.0f]]; [celltwo addsubview:preview]; [preview addtarget:self action:@selector(showpreviewseondsection:)forcontrolevents:uicontroleventtouchupinside]; preview.tag=indexpath.row;
and action as
-(ibaction)showpreviewseondsection:(id)sender { uibutton *button = (uibutton *)sender; nsinteger row = button.tag; nslog(@"tag of button %d",row); }
but confuse how load demopage link array view controller when section row button pressed @ index.
now update question first parsed -demopage key main array as
if (responsedata.length > 0) { nserror* error; self.json = [nsjsonserialization jsonobjectwithdata:responsedata options:kniloptions error:&error]; if ([[_json objectforkey:@"data"] iskindofclass:[nsarray class]]) { nsarray *arr = (nsarray *)[_json objectforkey:@"data"]; [self.imagearray addobjectsfromarray:arr]; [self.storeviewtable reloaddata]; } self.storeviewtable.hidden=false; } (index=0; index<[self.imagearray count]; index++) { nsdictionary *imgdict = [self.imagearray objectatindex:index]; if([imgdict count]>0) { nsmutablearray *imgslinkarray = [imgdict objectforkey:@"demopage"]; self.imagesa = imgslinkarray; } }
and set tag tableview cell button as
preview.tag=indexpath.row;
and action as
-(ibaction)showpreviewseondsection:(id)sender { uibutton *button = (uibutton *)sender; nsinteger row = button.tag; (index=0; index<[self.imagesa count]; index++) { if (row == 1) { previewviewcontroller *preview=[[previewviewcontroller alloc]initwithnibname:@"previewviewcontroller" bundle:nil]; preview.imagesa=self.imagesa; [self presentviewcontroller:preview animated:yes completion:nil]; nslog(@"preview array %@",preview.imagesa); } } }
then print -demopage array last index in scrollview please give me solution how press first button first index value , when press second cell button want print second index value.
while dealing multiple sections may help
in cellforrow
yourcell.tag=indexpath.section; yourcell.contentview.tag=indexpath.row;
and in preview action
-(void)previewbuttonaction:(id)sender { uibutton *button = (uibutton *)sender; // first, cast sender uibutton id rowid =[button superview]; id sectionid = [rwoid superview]; nsindexpath *indexpath = [nsindexpath indexpathforrow:[rowid tag] insection:[sectionid tag]]; // apply logic here depending on array row , section }
hope helps
Comments
Post a Comment