复杂的多视图iPhone iOS

4

我需要实现一个多视图应用程序,对我来说非常复杂,我需要一些建议。这个多视图应用程序类似于:

第一个视图:普通UIViewController,带有一个按钮,当我按下它时,进入第二个视图

第二个视图(也称为主视图):一个带有选项卡栏的窗口,有2个选项卡项可以在以下视图之间进行切换:

第二个视图A:普通UIViewController,带有一些元素

第二个视图B:UITableViewController

有人能给我一些建议,从哪里开始阅读或提供一些示例吗?

谢谢

2个回答

2
我的建议是从苹果的示例代码中阅读,那里你也可以找到编码如何做的好方法,祝你好运。或者你可以在Stack Overflow上搜索示例代码。例如基于导航的应用程序:UINavigationController doesn't work in a the moreNavigationController of a UITabBarController 或者简单的过渡:
SecondViewController *screen = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
        screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;


        [self presentModalViewController:screen animated:YES];

        [screen release];

希望这能有所帮助,再见。

wblade


1
你需要从视图为基础的应用程序开始。然后在你的 appDelegate 文件中创建一个 UITabbarController。

Appdelegate.h

UITabBarController *tabBarController;
// 设置属性

Appdelegate.m

// 合成

tabBarController = [[UITabBarController alloc] init];  
    tabBarController.delegate=self;  

//Adding Search,Nearby,Map,AboutUs,Favorites Tabs to tabBarController  
Search * search = [[Search alloc] init];  
UINavigationController *searchNav = [[UINavigationController alloc] initWithRootViewController:search];  

Nearby* nearby = [[Nearby alloc] init];  
UINavigationController *nearbyNav = [[UINavigationController alloc] initWithRootViewController:nearby];  

Map* map = [[Map alloc] init];  
UINavigationController *mapNav = [[UINavigationController alloc] initWithRootViewController:map];  

AboutUs* aboutUs = [[AboutUs alloc] init];  
UINavigationController *aboutUsNav = [[UINavigationController alloc] initWithRootViewController:aboutUs];  

Favorites* favorites = [[Favorites alloc] init];  
UINavigationController *favoritesNav = [[UINavigationController alloc] initWithRootViewController:favorites];  

NSArray* controllers = [NSArray arrayWithObjects:searchNav,nearbyNav,mapNav,aboutUsNav,favoritesNav, nil];  
tabBarController.viewControllers = controllers;  

[window addSubview:tabBarController.view];    

你可以相应地管理你想要放置导航控制器或仅视图控制器的选项卡。然后,在上述每个视图控制器中,您需要实现
- (id)init {}
在其中您可以设置选项卡名称和图像。

谢谢Stone,我需要释放/自动释放导航控制器和视图控制器吗?还是只有在退出时释放选项卡控制器? - Alessio Lunardelli
很高兴能帮上忙 :) 是的,你需要在退出之前释放它们以避免内存泄漏。 - Nitish

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接