...斐伊川
我已使用以下代码添加了标签栏和导航栏控制器。但只有在第一个选项卡上我添加了表视图和按钮,但它也显示在其他选项卡视图上。这段代码有什么问题我无法知道。如果有人知道,请帮助我。
- (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 makeKeyAndVisible];
return YES;
}
非常感谢。
答案 0 :(得分:0)
您为每个按钮分配相同的viewcontroller
控制器,但第二个按钮绑定到viewcontroller1
实例。也许这可能是问题。
如果要将表格视图和按钮添加到viewcontroller
实例,可能在viewDidLoad
方法中,这可能就是原因。