应用程序委托多个视图控制器的问题

时间:2015-08-31 06:46:11

标签: ios

我创建了标签栏控制器并在app delegate中实现但在此之前我还实现了其他视图控制器。我不知道如何使用它们有序地调用它们。请告诉我如何按照我喜欢的方式安排它们。 / p>

@interface AppDelegate ()
{
    UINavigationController *navigation;
}
@property (strong, nonatomic) JASidePanelController *viewController;
@property (strong, nonatomic) UITabBarController *this;


@end

@implementation AppDelegate
@synthesize viewController = _viewController;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    navigation = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];

    self.window.rootViewController = navigation;

//UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//        self.window = window;

    self.viewController = [[JASidePanelController alloc] init];
    self.viewController.shouldDelegateAutorotateToVisiblePanel = NO;

    self.viewController.leftPanel = [[LeftViewController alloc] init];



    UIViewController *viewcontroller1=[[HomeView alloc]init];
    UIViewController *viewcontroller2=[[Speciality alloc]init];
    UIViewController *viewcontroller3=[[Activity alloc]init];
    UIViewController *viewcontroller4 =[[Notification alloc]init];
    UIViewController *viewcontroller5 =[[Profile alloc]init];

    viewcontroller1.view.backgroundColor = [UIColor whiteColor];
    viewcontroller2.view.backgroundColor = [UIColor whiteColor];
    viewcontroller3.view.backgroundColor = [UIColor whiteColor];
    viewcontroller4.view.backgroundColor = [UIColor whiteColor];
    viewcontroller5.view.backgroundColor = [UIColor whiteColor];



    UINavigationController *navcontroller1=[[UINavigationController alloc] initWithRootViewController:viewcontroller1];
    UINavigationController *navcontroller2=[[UINavigationController alloc] initWithRootViewController:viewcontroller2];
    UINavigationController *navcontroller3=[[UINavigationController alloc] initWithRootViewController:viewcontroller3];
    UINavigationController *navcontroller4 =[[UINavigationController alloc] initWithRootViewController:viewcontroller4];
    UINavigationController *navcontroller5 =[[UINavigationController alloc] initWithRootViewController:viewcontroller5];


    viewcontroller1.title = @"Home";
    viewcontroller2.title = @"Speciality";
    viewcontroller3.title = @"Activity";
    viewcontroller4.title = @"Notification";
    viewcontroller5.title = @"Profile";

    navcontroller1.tabBarItem.image = [UIImage imageNamed:@"home"];
    navcontroller2.tabBarItem.image = [UIImage imageNamed:@"special"];
    navcontroller3.tabBarItem.image = [UIImage imageNamed:@"activity"];
    navcontroller4.tabBarItem.image = [UIImage imageNamed:@"notify"];
    navcontroller5.tabBarItem.image = [UIImage imageNamed:@"Pro"];

    self.this = [[UITabBarController alloc] init];

    self.this.viewControllers=[NSArray arrayWithObjects:navcontroller1,navcontroller2,navcontroller3,navcontroller4,navcontroller5, nil];

    self.this.tabBar.barTintColor =  RGBCOLOR(249, 178, 131);

    self.viewController.centerPanel = _this;


    [self.window makeKeyAndVisible];
    return YES;
}

1 个答案:

答案 0 :(得分:0)

在此,您将窗口的根控制器设置为导航控制器:

self.window.rootViewController = navigation;

然后你继续实例化一些其他导航控制器并将它们添加到选项卡控制器。从您的问题中不清楚您尝试实现的目标,但如果您希望自己的应用使用标签控制器,则需要将窗口的根控制器设置为标签控制器,而不是导航控制器。