iphone sdk uitabbarcontroller 不起作用

发布于 2024-10-08 20:25:37 字数 645 浏览 1 评论 0原文

我正在尝试创建 3 个 Tabbar 控件,但第三个不显示页面,有人知道代码有什么问题吗?提前致谢。

        FirstViewController* viewController1 = [[FirstViewController alloc]init]; 
 MySecondViewController* viewController2 = [[MySecondViewController alloc]init];
 MyThirdViewController* viewController3 = [[MyThirdViewController alloc]init];


 NSArray* controllersArray = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, nil];              
 tabController = [[UITabBarController alloc]init];
 [tabController setViewControllers:controllersArray]; 

 [viewController1 release];
 [viewController2 release];
 [viewController3 release];

I'm trying to create 3 Tabbar control but the third one does not display the page, anyone know what's wrong with the code? Thanx in advance.

        FirstViewController* viewController1 = [[FirstViewController alloc]init]; 
 MySecondViewController* viewController2 = [[MySecondViewController alloc]init];
 MyThirdViewController* viewController3 = [[MyThirdViewController alloc]init];


 NSArray* controllersArray = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, nil];              
 tabController = [[UITabBarController alloc]init];
 [tabController setViewControllers:controllersArray]; 

 [viewController1 release];
 [viewController2 release];
 [viewController3 release];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

想念有你 2024-10-15 20:25:37

由于没有提供其他代码,我举一个例子。扩展您的类,使用 UITabBarController 随意命名它。然后在你的 UITabBarController 子类中做这样的事情。

FirstViewController *vc1 = [[FirstViewController alloc] init];
SecondViewController *vc2 = [[SecondViewController alloc] init];
ThirdViewController *vc3 = [[ThirdViewController alloc] init];

NSArray *array = [[NSArray alloc] initWithObjects: vc1, vc2, vc3, nil];

self.controllers = array;

[vc1 release];
[vc2 release];
[vc3 release];
[array release];

然后你只需在上面列出的三个类中设置文本和 tabbarimage 即可。

一个例子是:

[self.tabBarItem setTitle:@"FirstViewController"];
[self.tabBarItem setImage:[UIImage imageNamed:IMAGEPATH]];

Since no other code is provided, I give you an example. Extend your class, call it whatever you want with UITabBarController. Then in your UITabBarController subclass do something like this.

FirstViewController *vc1 = [[FirstViewController alloc] init];
SecondViewController *vc2 = [[SecondViewController alloc] init];
ThirdViewController *vc3 = [[ThirdViewController alloc] init];

NSArray *array = [[NSArray alloc] initWithObjects: vc1, vc2, vc3, nil];

self.controllers = array;

[vc1 release];
[vc2 release];
[vc3 release];
[array release];

Then you just have to set up the text and tabbarimage in the three classes listed above.

An example would be:

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