Iphone UINavigationController+;尤塔巴。viewDidLoad中的垂直定位错误

Iphone UINavigationController+;尤塔巴。viewDidLoad中的垂直定位错误,iphone,objective-c,uinavigationcontroller,uitabbar,xcode4.5,Iphone,Objective C,Uinavigationcontroller,Uitabbar,Xcode4.5,使用XCode 4.5和iOS6 我创建了一个带有UITabBar(NIBs)的UINavigationController,第一次启动时的选项卡垂直定位不正确。单击第二个选项卡和第一个选项卡时,垂直定位正常 所以。。。第一次运行完成后,如何正确定位第一个选项卡 请参见错误定位: 我的代码: AppDelegate.h @interface bib_AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDe

使用XCode 4.5和iOS6

我创建了一个带有UITabBar(NIBs)的UINavigationController,第一次启动时的选项卡垂直定位不正确。单击第二个选项卡和第一个选项卡时,垂直定位正常

所以。。。第一次运行完成后,如何正确定位第一个选项卡

请参见错误定位:

我的代码:

AppDelegate.h

@interface bib_AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UINavigationController *mainControllercode;
@property (strong, nonatomic) UITabBarController *tabBarController;
代理控制器

#import <UIKit/UIKit.h>

@interface agendaViewController : UIViewController
@end
编辑1:


我创建了一个示例项目,其中包含您可以看到的故事板。我想在没有故事板的情况下拥有相同的功能,请在此处下载:


谢谢

你走错了路

UITabBarController应该有一组UINavigationController,然后将其根控制器设置为主Nib。然后,每个选项卡处理自己的导航堆栈

您当前正在将UITabBarController放入UINavigationController的根目录中。当您在导航堆栈中移动时,这将导致问题以及移除选项卡栏

有关以编程方式处理的详细信息,请查看此链接:


谢谢您的回复。但我只想要一个主导航栏,这可以用故事板来完成,所以我想也可以用笔尖来完成。此外,我也没有发现删除tabbarI创建了一个带有故事板的示例项目的问题,您可以看到。我想有相同的功能,没有故事板不幸的是,主机被我的isp阻止。您可以将其上传到其他地方或创建github存储库吗?
#import <UIKit/UIKit.h>

@interface agendaViewController : UIViewController
@end
#import "agendaViewController.h"

@interface agendaViewController ()

@end

@implementation agendaViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    self.title = NSLocalizedString(@"Agenda", @"Agenda");
    self.tabBarItem.image = [UIImage imageNamed:@"83-calendar"];
}
return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
     // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end