iphone - 错误 : Creating Tab-Navigation programmatically

标签 iphone objective-c ios tabbar navigationbar

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

我想使用 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/

相关文章:

ios - 使用 mailcore (iOS),我怎样才能从特定的电子邮件地址获取所有电子邮件?

网络应用程序的 iPhone 推送通知?

ios - UITableViewCell 中的内容未显示

iphone - 如何从 iOS 中包含图像的 URL 获取数据?

ios - 带有切出段和阴影的 UIView

ios - Xcode Convert to ARC, Create universal binary fails with error of "can' t 找出架构类型”

jquery - 用于 iOS 开发的 Webkit 桌面浏览器

ios - heightForImageCellAtIndexPath 中 dispatch_once 的原因

当屏幕快速关闭时,IOS 音频停止播放

iphone - 带有静态单元格的 UITableViewController : contentSize is {0, 0}