viewDidAppear 未调用

发布于 2024-10-07 18:45:11 字数 1204 浏览 1 评论 0原文

我添加了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白芷 2024-10-14 18:45:11

嘿,您确定要使用 loadView 而不是使用 viewDidLoad 吗?
当你调用这个视图控制器时,你可以粘贴代码吗?
顺便说一句,“self.view = contentView”?也许 [self.view addSubview:contentView] 听起来更好,你不觉得吗?

Hey, are you sure you want to work with loadView and not with viewDidLoad 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文