2010-12-13 185 views
0

我已經添加了tabbarcontroller,setViewControllers用於提供uiviewcontroller數組。 viewDidLoad被調用這個viewContollers,但不是viewDidAppear既不viewWillAppear。 代碼我已經寫viewDidAppear not called

 

- (void)loadView { 
printf("*********\n loadView \n********* "); 
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; 
contentView.backgroundColor = [UIColor whiteColor]; 
self.view = contentView; 
[contentView release]; 
UITabBarController *tabbar = [[UITabBarController alloc] init]; 
tabbar.view.frame = CGRectMake(0, 0, 320, 460); 
piechartViewController *pr=[[piechartViewController alloc]init]; 
pr.tagInAction=1; 
[email protected]"Type"; 
pr.tabBarItem.image=[UIImage imageNamed:@"trend.png"]; 
pr.sDate=sDate; 
pr.nDate=nDate; 
piechartViewController *pr1=[[piechartViewController alloc]init]; 
[email protected]"category"; 
pr1.tagInAction=4; 
pr1.sDate=sDate; 
pr1.nDate=nDate; 
piechartViewController *pr2=[[piechartViewController alloc]init]; 
[email protected]"paidWith"; 
pr2.tagInAction=3; 
pr2.sDate=sDate; 
pr2.nDate=nDate; 
[tabbar setViewControllers:[NSArray arrayWithObjects:pr,pr1,pr2,nil]]; 
[self.view addSubview:tabbar.view ]; 
[pr release]; 
[pr1 release]; 
[pr2 release]; 
} 
 

回答

0

嘿,你確定你想與loadView,而不是與viewDidLoad而不是工作? 你可以在調用這個視圖控制器時粘貼代碼嗎? 順便說一句,「self.view = contentView」?可能[self.view addSubview:contentView]聽起來更好,你不覺得嗎?