gpt4 book ai didi

iphone - 错误 : Creating Tab-Navigation programmatically

转载 作者:行者123 更新时间:2023-11-28 23:01:37 25 4
gpt4 key购买 nike

如果这个问题已经发布,请原谅..

我想使用 XCode 4.2 和 iPhone SDK 5.0 以编程方式创建 TabBar 和 NavigationBar 的组合

它按预期产生视觉效果..但是当按下(粘贴)TabBarItem 以更改其相应 View 时,它会产生错误:[__NSCFString _tabBarItemClicked:]: unrecognized selector sent to instance

下面是 AppDelegat

的实现
#import "ApplicationDelegat.h"
#import "BrightnessController.h"


@implementation ApplicationDelegat

@synthesize window;
//@synthesize bControl;



- (void)applicationDidFinishLaunching:(UIApplication *)application
{
NSMutableArray *controllers = [NSMutableArray array];
UITabBarController *tbarController = [[UITabBarController alloc] init];

for (int i = 0; i <= 3; i++)
{
//self.bControl = [[BrightnessController alloc] initWithBrightness:i];
BrightnessController *bControl = [[BrightnessController alloc] initWithBrightness:i];

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController: /*self.bControl*/bControl];

nav.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[controllers addObject: nav];
//bControl.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"test" image:nil tag:i];
//tbarController.navigationController.delegate = self;
}

tbarController.viewControllers = controllers;
tbarController.customizableViewControllers = controllers;
tbarController.selectedIndex = 0;
tbarController.delegate = self;

// NSCFString
//tabBarItem

// Set up the window
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

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

@end

我不知道为什么会发生以及如何恢复它..有人帮助我。

如果需要更多细节,我可以提供源代码...

提前致谢。

最佳答案

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController; 7:20
switch(mytabbar.selectedIndex)
{
case 0:
[imageView1 setImage:[UIImage imageNamed:@"Tab1_sel.png"]];
[imageView2 setImage:[UIImage imageNamed:@"Tab2.png"]];
[imageView3 setImage:[UIImage imageNamed:@"Tab3.png"]];
[imageView4 setImage:[UIImage imageNamed:@"Tab4.png"]];
[imageView5 setImage:[UIImage imageNamed:@"Tab5.png"]];
break;

case 1:

您可以使用此方法并更改每个标签栏的点击索引

关于iphone - 错误 : Creating Tab-Navigation programmatically,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9926585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com