简体   繁体   中英

Pushing the ViewController in customize Tableview Cell

I'm using Using Customize table cell and have a button action in that cell and tapping on that should take me to another ViewController, I'm using this code inside the button action but its not working out:

 PhotoViewController *photo = [[PhotoViewController alloc]initWithNibName:@"PhotoViewController" bundle:nil];
  [self.navigationController pushViewController:photo animated:YES];

Got the solution :-) thanks Created the IBOutlet and in cellForRowAtIndexPath method declared:

 cell.photoAlbum.tag = indexPath.row; [cell.photoAlbum addTarget:self 
action:@selector(photoAblumClicked:) forControlEvents:UIControlEventTouchUpInside]; 

and in the photoAblumClicked called the above code it's working fine Thanks :-)

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *tableIdentifier = @"StaticTableViewCell"; StaticTableViewCell *cell = (FriendTableViewCell *)[tableView dequeueReusableCellWithIdentifier:tableIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"StaticTableViewCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } cell.button.tag = indexPath.row; [cell.button addTarget:self action:@selector(PhotoAlb:) forControlEvents:UIControlEventTouchUpInside]; return cell; } 
-(void)PhotoAlb:(id)sender
{
    PhotoViewController *photo = [[PhotoViewController alloc]initWithNibName:@"PhotoViewController" bundle:nil];
    [self.navigationController pushViewController:photo animated:YES];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM