2012-08-10 39 views
0

在one.m爲什麼該值不會傳遞到下一個TabbarViewController?

- (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 
+0

您是否認爲汽車?你爲什麼從UITabBarController繼承?你是用'car'還是'self.car'來引用汽車? – 2012-08-10 11:52:41

+0

謝謝你的回覆,我很確定我認爲汽車和汽車不是self.car – jxdwinter 2012-08-10 12:03:41

+0

你可以發佈@synthesize的代碼嗎?出於好奇,如果你使用'self.car'而不是'car',會發生什麼? – 2012-08-10 12:08:39

回答

0

@PeterPajchl:你不應該推的UITabBarController實例上的UINavigationController的堆棧 - 查看文檔。

相關問題