通过segue传输视图控制器后隐藏单元格

时间:2013-06-18 05:29:18

标签: iphone ios xcode storyboard segue

通过segue更改文本后,我试图通过segue隐藏一个单元格。这没用。这是我的代码:

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

    TerminalsViewController *transferViewController = segue.destinationViewController;

    NSLog(@"prepareForSegue: %@", segue.identifier);
    if([segue.identifier isEqualToString:@"firstSegue"])
    {
        transferViewController.term1Text = @"Joe Smith";
        transferViewController.term2Text = @"555-555-5556";
        transferViewController.term3Text = @"06/27/1984";

    }else if([segue.identifier isEqualToString:@"thirdSegue"]){
        transferViewController.term1Text = @"John Smith";
        transferViewController.term2Text = @"555-555-5556";
        transferViewController.term3Text = @"06/27/1972";
        transferViewController.cell1.hidden = YES;

    }

}

这样做的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

prepareForSegue:

TerminalsViewController *transferViewController = segue.destinationViewController;

NSLog(@"prepareForSegue: %@", segue.identifier);
if([segue.identifier isEqualToString:@"firstSegue"])
{
    transferViewController.term1Text = @"Joe Smith";
    transferViewController.term2Text = @"555-555-5556";
    transferViewController.term3Text = @"06/27/1984";

}else if([segue.identifier isEqualToString:@"thirdSegue"]){
    transferViewController.term1Text = @"John Smith";
    transferViewController.term2Text = @"555-555-5556";
    transferViewController.term3Text = @"06/27/1972";
    transferViewController.hideCell = YES;

}

TransferViewController.h:

@property (nonatomic) boolean hideCell;

TransferViewController.m:

@synthesize hideCell;

TransferViewController.m:的cellForRowAtIndexPath:

if (hideCell) {
    cell1.hidden = YES;
}