开发者

Additions of tabbar and navigation bar controllers

开发者 https://www.devze.com 2023-03-11 15:03 出处:网络
Hii... I have added the tabbar and navigation bar controller by using following code. But only on the first tab I have added table view and buttons but it is also displaying on others tab views. What

Hii...

I have added the tabbar and navigation bar controller by using following code. But only on the first tab I have added table view and buttons but it is also displaying on others tab views. What is the problem with this code I am not able to come to know. please help me If anyone know.

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

    // Override point for customization after application launch.
    //UITabBarController *tab =[[UITabBarController alloc]init];

    vc1 = [[viewcontroller alloc] init];
     nc = [[UINavigationController alloc] initWithRootViewController:vc1];
    //vc1.tabBarItem.image = [UIImage imageNamed:@"tab.png"];
    vc2 = [[viewcontroller1 alloc] init];
    nc1 = [[UINavigationController alloc] initWithRootViewController:vc2];

    vc3 = [[viewcontroller alloc] init];
    nc2 = [[UINavigationController alloc] initWithRootViewController:vc3];

    vc4 = [[viewcontroller alloc] init];
    nc3 = [[UINavigationController alloc] initWithRootViewController:vc4];

    vc5 = [[viewcontroller alloc] init];
    nc4 = [[UINavigationController alloc] initWithRootViewController:vc5];

    NSArray *navControllers = [NSArray arrayWithObjects:nc, nc1, nc2, nc3, nc4, nil];
    [nc release]; 
    [nc1 release];
    [nc2 release];
    [nc3 release];
    [nc4 release];

    tab = [[UITabBarController alloc] init];
    [tab setViewControllers:navControllers];

    [window addSubview:[tab view]];
    [window makeKeyAndVisible];

    //return YES;

   // [window makeKeyA开发者_JAVA技巧ndVisible];

    return YES;
}

Thanks alot.


You are allocating the same viewcontroller controller for each button except the second one, that is bound to a viewcontroller1 instance. Maybe this could be the problem.

If you are adding the table view and buttons to the viewcontroller instances, maybe in the viewDidLoad method, this could be the cause.

0

精彩评论

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

关注公众号