I have an app that displays, in a tableview
, an image and some details. I'm trying to make it so that, when someone touches on the image displayed in my table view, the app opens the same image in a bigger size, with the ability to navigate between them.
This is my 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 is the function when the image is 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 I try this, the app just crashes.