2014-07-05 35 views
3

我使用的自定義表格單元格,在該單元的按鈕操作和攻絲上應該帶我到另一個ViewController中,我使用這個代碼的按鈕動作裏面,但它不是工作了:推視圖控制器在定製泰伯維細胞

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

ü沒有你的IBAction爲方法應用調試器?該方法是否在您的水龍頭上打電話? – iProgrammer

+0

@iProgrammer:不,我正好DONOü意味着,我有什麼創建該按鈕的IB操作方法,並通過上面的代碼在方法 – satishiOS25

+0

@ user3807171不知道什麼您的評論意味着 - 我只是試圖讓你的問題更清晰讓別人來幫助你。 –

回答

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

了:-)感謝創造了IBOutlet中和的cellForRowAtIndexPath方法解決宣稱:

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

,並在photoAblumClicked叫上面的代碼它的工作很好,謝謝:-)

相關問題