0

我实现了一个 TabBar 控制器,它是这样初始化的

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
     firstView = [[FirstView alloc]init];
     secondView = [[SecondView alloc]init];

     firstItem = [[UITabBarItem alloc]initWithTitle:@"First" image:nil tag:0];
     secondItem = [[UITabBarItem alloc]initWithTitle:@"Second" image:nil tag:1];

     firstView.tabBarItem = firstItem;
     secondView.tabBarItem = secondItem;


     NSArray *viewArray = [[NSArray alloc]initWithObjects:firstView, secondView, nil];
     [self setViewControllers:viewArray];
    }
return self;
}

在 AppDidFinishedLoading 我只是这样做了:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
mainbarController = [[MainBarController alloc]initWithNibName:@"MainBarController" bundle:nil];
[self.window setRootViewController:mainbarController];
[self.window makeKeyAndVisible];
return YES;
}

我的问题是,我想将 tabBar 放在其他地方,而不是在底部,就像我运行项目时那样。但我找不到我的代码的 xib 文件。mainwindow.xib 只是一个空窗口。我知道这是非常基本的,但我对此感到困惑。

不管怎么说,还是要谢谢你

4

0 回答 0