ios - Tapping on UIImageView and opening a bigger Image -
i have app displays, in tableview, image , details. i'm trying make that, when touches on image displayed in table view, app opens same image in bigger size, ability navigate between them.
this current code:
singletap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(imgtapped:)]; singletap.numberoftapsrequired =1; singletap.numberoftouchesrequired = 1; -(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section{ return [json count]; } -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{ uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"mycell"]; if(cell == nil){ [[nsbundle mainbundle] loadnibnamed:@"agendacell" owner:self options:nil]; cell = self.agendacell; } agendacell.datecell.text = [[json objectatindex:[indexpath row]] objectforkey:@"date"]; agendacell.enderecocell.text = [[json objectatindex:[indexpath row]] objectforkey:@"endereco"]; agendacell.titulocell.text = [[json objectatindex:[indexpath row]] objectforkey:@"titulo"]; [agendacell.imgcell setimagewithurl:[nsurl urlwithstring:@"http://sallescds.com.br/wp-content/uploads/2012/12/xepop-300x300.jpg"] placeholderimage:[uiimage imagenamed:@"placeholder.png"]]; [agendacell.imgcell setuserinteractionenabled:yes]; [agendacell.imgcell addgesturerecognizer:singletap]; return cell; } here function when image tapped:
-(void)imgtapped:(uigesturerecognizer *)gesturerecognizer{ nslog(@"detectado o click no uiimageview bitch!"); imgdetailviewcontroller *imgview = [[imgdetailviewcontroller alloc] initwithnibname:@"imgdetailviewcontroller" bundle:nil]; [self.navigationcontroller pushviewcontroller:imgview animated:yes]; } when try this, app crashes.
i don't know how you're setting agendacell, line says:
if (cell == nil) { [[nsbundle mainbundle] loadnibnamed:@"agendacell" owner:self options:nil]; cell = self.agendacell; } would be:
if (cell == nil) { nsarray *nibobjects = [[nsbundle mainbundle] loadnibnamed:@"agendacell" owner:self options:nil]; cell = [nibobjects objectatindex:0]; }
Comments
Post a Comment