viewDidAppear 未调用
我添加了 tabbarcontroller、setViewControllers 用于提供 uiviewcontroller 数组。为此 viewContollers 调用 viewDidLoad,但不会调用 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];
}
I have added tabbarcontroller, setViewControllers used for providing array of uiviewcontroller. viewDidLoad is called for this viewContollers but not viewDidAppear neither viewWillAppear.
the code I have written
- (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];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嘿,您确定要使用
loadView
而不是使用viewDidLoad
吗?当你调用这个视图控制器时,你可以粘贴代码吗?
顺便说一句,“
self.view = contentView
”?也许[self.view addSubview:contentView]
听起来更好,你不觉得吗?Hey, are you sure you want to work with
loadView
and not withviewDidLoad
instead?And might you paste the code when you call this view controller?
Btw, "
self.view = contentView
"? Probably[self.view addSubview:contentView]
sounds better, don't you think?