2016-04-27 57 views
0

到的ViewController我用它在Objective-C的一個XIB文件庫編程方式從廈門國際銀行文件創建賽格瑞在故事板

我有我的故事板具有迅速類

我需要從廈門國際銀行創造SEGUE文件到我的故事板並傳遞一些數據。

試圖與沒有運氣

XIB文件

#import "IncomingMessageCell.h" 

@implementation IncomingMessageCell 

- (void)awakeFromNib { 

    UIImage * balloonImage = [UIImage imageNamed:@"bubble-left"]; 
    balloonImage = [balloonImage resizableImageWithCapInsets:(UIEdgeInsets){36, 32, 18, 12}]; 
    self.bubbleView.image = balloonImage; 

    self.avatarView.layer.cornerRadius = 25; 
    self.avatarView.clipsToBounds = YES; 

    self.avatarView.userInteractionEnabled = YES; 

    UITapGestureRecognizer *tapGesture1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)]; 

    tapGesture1.numberOfTapsRequired = 1; 

    [tapGesture1 setDelegate:self]; 

    [self.avatarView addGestureRecognizer:tapGesture1]; 
    } 

- (void) tapGesture: (id)sender 
{ 
    UIViewController *vc = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"yourVcIdentifier"]; 
[self.navigationController pushViewController:vc animated:YES]; 
} 


- (void)setSelected:(BOOL)selected animated:(BOOL)animated { 
    [super setSelected:selected animated:animated]; 

    // Configure the view for the selected state 
} 

@end 

這怎麼可能?

+0

你在哪裏試試這個?你現在的VC是什麼? –

+0

我更新了我的問題 –

+0

,那麼當您點擊時會發生什麼? –

回答

0

像這樣在ViewController中保存tableview與這個單元格。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    IncomingMessageCell *cell = ...; 
    cell.avatarView.userInteractionEnabled = YES; 

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; 
    tapGesture.numberOfTapsRequired = 1; 
    [cell.avatarView addGestureRecognizer:tapGesture]; 
    cell.avatarView.tag = 500 + indexPath.row; // To detect cell that image belongs to, because you use dequeue cell 
    return cell; 
} 

- (IBAction)handleTapGesture:(UITapGestureRecognizer *)tapGesture{ 
    //Do you action 
    NSLog(@"Row tap : %ld",tapGesture.view.tag - 500); 
    UIViewController *vc = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"yourVcIdentifier"]; 
    [self.navigationController pushViewController:vc animated:YES]; 
} 
+0

我可以處理點擊已經但我不知道如何繼續到主要故事板 –

+0

是的,但是爲了處理segue,你應該把你的代碼放在ViewController中而不是Cell中。 試試我的方法,你可以把你的代碼推到另一種觀點認爲: ' - (IBAction爲)handleCellBtnClicked:(UIButton的*)發件人{// 你行動 的UIViewController * VC = [[UIStoryboard storyboardWithName:@「MainStoryboard 「bundle:nil] instantiateViewControllerWithIdentifier:@」yourVcIdentifier「]; [self.navigationController pushViewController:vc animated:YES]; }' –

+0

我們不能使用來自cellForRowAtIndexPath的tabgesture? –