开发者

How to add simple viewcontroller at start up in tabbar application

开发者 https://www.devze.com 2023-02-08 00:44 出处:网络
I was doing great till now with my tabbar application. But now I have to add one viewcontroller at start of application and based on selection on that view have to go on specific tab of my tabcontroll

I was doing great till now with my tabbar application. But now I have to add one viewcontroller at start of application and based on selection on that view have to go on specific tab of my tabcontroller.

W开发者_运维知识库hat I thought to do is change my start up in AppDelegate to new viewcontroller instead of tabbarcontroller, which I did like this:

 - (BOOL)application:(UIApplication *)application    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    


// Add the view controller's view to the window and display.
[self.window addSubview:viewController.view];
[self.window makeKeyAndVisible];

return YES;

}

And then call a appdelegate method on button click in new startup view to switch to tabbarcontroller, code is:

  -(IBAction)btnTab:(id)sender{


 [(AppDelegate *) [[UIApplication sharedApplication] delegate] ChangeView];
}

//ChangeView method in AppDelegate:

 -(void)ChangeView{

[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
}

But problem is I can't see my new view with button on startup, just a blank view is coming...any suggestions?


I'm pretty sure that your tabBarController is nil.

0

精彩评论

暂无评论...
验证码 换一张
取 消