-->

Complex multiview iphone ios

2019-05-11 11:03发布

问题:

i need to implement a multiview app really complex to me and i need some advice. The multiview app is something like:

First view: Normal UIViewController with one button, when i push it go to second view Second view(aka mainview): a Windows with Tab Bar with 2 tabbar item who switch between: Second view A: Normal UIViewController with some elements Second view B: UITableViewController

Can someone give me an advice where to start reading or some examples?

thx

回答1:

You need to start with view based application. And then create a UITabbarController in you appDelegate file.

Appdelegate.h

UITabBarController *tabBarController;
// set properties

Appdelegate.m

// Synthsize

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];    

You can accordingly manage in which tab you want to place navigation controller or only a view controller.

Then in each of the view controllers mentioned above you need to implement
- (id)init {}
in which you can set Tab name and image.



回答2:

my advice is to read sample code form apple there you can also find coding how to s so good luck, or you can find example codes all over the stack just search. for example navigation based app: UINavigationController doesn't work in a the moreNavigationController of a UITabBarController

or simple transition:

SecondViewController *screen = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
        screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;


        [self presentModalViewController:screen animated:YES];

        [screen release];

hope it helps bye

wblade