1

我遇到了问题,UITabBarController因为我对第一个视图的第一个视图UIViewController与底部偏移了大约 20 个像素。每当我切换和/或返回第一个视图控制器(相同的实例,未释放)时,它都很好。这只是第一次见面。

我的步骤:

  1. 我正在分配和初始化一个UITabBarController
  2. 我正在分配和初始化 3 个实例UIViewController
  3. 我将viewControllers属性设置为上述 3 项的数组

我的代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Allocate and initialize view controllers
    self.debtsViewController = [[DebtsViewController alloc] init];
    self.debtsViewController.title = NSLocalizedString(@"Debts", nil);
    self.debtsViewController.tabBarController = self;
    self.conclusionsViewController = [[ConclusionsViewController alloc] init];
    self.conclusionsViewController.title = NSLocalizedString(@"Entries", nil);
    self.conclusionsViewController.tabBarController = self;
    self.settingsViewController = [[SettingsViewController alloc] init];
    self.settingsViewController.title = NSLocalizedString(@"Settings", nil);
    // Assign to tabBarController
    self.viewControllers = [NSArray arrayWithObjects:self.debtsViewController, self.conclusionsViewController, self.settingsViewController, nil];
}

有任何想法吗?

截图:http ://cl.ly/image/2E0S001d0Q2x (注意上方的黑色空间UITableViewController

4

2 回答 2

1

我解决了这个问题。

```

[tab setSelectedIndex:1];
[tab setSelectedIndex:0];

```

您可以在 tabbarcontroller 初始化后通过切换标签栏手动重置偏移量

于 2013-10-24T09:22:37.930 回答
0

看了一眼你的截图让我想到,实际上你应该UINavigationControllersUITabBarViewController. 他们的导航栏将(几乎)看起来相似,但它将是 3 个单独的实例。“设置”与“债务”有什么共同点?为什么他们会共享相同的导航?

使用的重点UITabBarViewController是拥有应用程序的独立部分。我强烈推荐你苹果的指南。

于 2013-03-25T21:34:59.300 回答