【问题标题】:Black UIViewController when pushing but not when presenting modally推送时黑色 UIViewController 但在模态呈现时不显示
【发布时间】:2013-07-29 09:12:58
【问题描述】:

我很难使用 UIViewController...
我有这个 UINavigationController,它的根视图控制器包含一个 UITableView,它推动一个 UIViewController 打开单元格选择。

示例代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    MySecondViewController *controller = [[MySecondViewController alloc] initWithNibName:@"MySecondViewController" bundle:nil];
    [self.navigationController pushViewController:controller animated:YES];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

除非它没有按预期工作!
推送时,它的动画效果很好,但不是我的 UIViewController,而是黑屏。

奇怪的是,我可以毫无问题地以模态方式呈现它。
我也可以毫无问题地推送其他 UIViewControllers!

我查找了有关此类问题的其他帖子,但找不到。
其他人似乎忘记了链接他们的 xib 或设置 rootViewController 之类的东西。

任何提示将不胜感激。

【问题讨论】:

  • 您检查过您的 XIB 名称“MySecondViewController”吗?是真的吗?
  • 你是推控制器还是programVC?
  • UInavigation 控制器可能会导致此问题。使用 UInavigationController 正确检查。
  • 您正在推动“programVC”而不是“控制器”。
  • @Bhargavi 是的,我检查了我的 xib,并且由于它在模态呈现时显示,我认为 xib 不是罪魁祸首。而且由于我可以推送其他视图控制器而不会出现问题,所以我看不出导航控制器是如何受到指责的。这是一个非常奇怪的行为!至于你的其他提示,对不起,我只是忘记在我提供的示例代码中更改变量的名称。果然我没有叫我的控制器'MySecondViewController'。

标签: ios ipad uiviewcontroller uinavigationcontroller


【解决方案1】:

请注意,我想通了!

原来是我使用的第 3 方库导致了问题。
它刚刚更新,显然与我的实现不兼容。
我仍然不知道为什么它会这样失败,但恢复到以前的版本就可以了。
我在 viewDidLoadof MySecondViewController 中初始化它。

感谢您的提示。

【讨论】:

  • 第三方库是……?
【解决方案2】:

试试这个。 问题:错误的 VC 推送

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    MySecondViewController *controller = [[MySecondViewController alloc] initWithNibName:@"MySecondViewController" bundle:nil];
    [self.navigationController pushViewController:controller animated:YES];
}

【讨论】:

  • 抱歉,我的变量拼错了,这不适用于特定的视图控制器,但适用于任何其他视图控制器!
猜你喜欢
  • 1970-01-01
  • 2018-01-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多