为什么值没有传递给下一个TabbarViewController?

时间:2012-08-10 11:49:59

标签: ios uitabbarcontroller

在one.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger row = [indexPath row];
    NSString *carNumber = [self.carNumberArrayFromPlistFile objectAtIndex:row];
    NSString *engineNumber  = [self.engineNumberArrayFromPlistFile objectAtIndex:row];
    CarInfo *oneCarInfo = [[CarInfo alloc] initWithCarNumber:carNumber engineNumber:engineNumber];
    Two *two = [[Two alloc] initWithNibName:@"Two" bundle:nil];
    two.car = oneCarInfo;
    [self.navigationController pushViewController:two animated:YES];
    [oneCarInfo release];
    [two release];
}

在two.h中

@interface Two : UITabBarController
{
    CarInfo *car;
}
@property (nonatomic, retain)CarInfo *car;

为什么Two.m中的车总是空的?请帮我解决一下这个。谢谢你们!

Two.m:

@interface Two ()
@end

@implementation Two
@synthesize car;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    // Custom initialization
    }
    return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];   
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    self.car = nil;
}

- (void)dealloc
{
    [super dealloc];
}
@end

1 个答案:

答案 0 :(得分:0)

@PeterPajchl:您不应该将UITabBarController的实例推送到UINavigationController的堆栈上 - 请查看文档。