2012-01-16 14 views
0

ボタン付きのUIViewControllerがあります。ボタンはfirstTableViewController - > tabViewController(3つのタブ) - >タブの1つにsecondTableViewController - > UIViewControllerがあります。prepareForSequeは起動しません。

すべてがストーリーボードにあります。

firstTableViewControllerではprepareForSequeが正常に動作します。私はdidSelectRowを持っていません...

しかし、secondForTableViewControllerではprepareForSequeは起動しません。そこでdidSelectRowAtIndexPathを次のように追加しました。しかし、prepareForSegueはまだ動作しません。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [self performSegueWithIdentifier:@"ShowComment" sender:self]; 
} 

-(void) performSegueWithIdentifier:(NSString *)identifier sender:(id)sender 
{ 
    [self prepareForSegue:self.storyboard sender:self]; 
} 

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 


    //When a row is selected, the segue creates the detail view controller as the destination.  
    //Set the detail view controller's detail item to the item associated with the selected row. 
NSLog(@"test"); 
    if ([[segue identifier] isEqualToString:@"ShowComment"]) { 

    } 
} 

答えて

0

問題が見つかりました。私はセルの識別子を持っていませんでした。ストーリーボードのプロトタイプセルを、属性インスペクタ - >識別子 'Cell1'に入力して選択しました。コードで

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell1"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

    // Configure the cell... 
    Note *note = [notes objectAtIndex:indexPath.row]; 
    cell.textLabel.text = note.title; 
    return cell; 
} 

出来上がり、それが働きました。

関連する問題