我添加了tabbarcontroller,用于提供uiviewcontroller数组的setViewControllers。 viewDidLoad为此viewContollers调用,但viewDidAppear不调用viewWillAppear。 我写的代码
- (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;
pr.title=@"Type";
pr.tabBarItem.image=[UIImage imageNamed:@"trend.png"];
pr.sDate=sDate;
pr.nDate=nDate;
piechartViewController *pr1=[[piechartViewController alloc]init];
pr1.title=@"category";
pr1.tagInAction=4;
pr1.sDate=sDate;
pr1.nDate=nDate;
piechartViewController *pr2=[[piechartViewController alloc]init];
pr2.title=@"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 :(得分:0)
嘿,您确定要与loadView
合作,而不是与viewDidLoad
合作吗?
你可以在调用这个视图控制器时粘贴代码吗?
顺便说一下,“self.view = contentView
”?可能[self.view addSubview:contentView]
听起来更好,你不觉得吗?