我正在使用“使用定制表”单元格,并且在该单元格中有一个按钮动作,然后点击它应将我带到另一个ViewController,我在按钮动作中使用了此代码,但无法解决:

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

最佳答案

- (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];
}

10-08 06:25