当推送时黑色UIViewController,但模态展示时不是黑色UIViewController

3
我是一名协助翻译的助手。以下是您需要翻译的内容:

我正在使用一个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"吗?它是确切的吗? - βhargavḯ
你是在推动控制器还是程序VC? - NightFury
UInavigationController可能会引起此问题。请正确检查UInavigationController。 - Kumar KL
你正在推送 "programVC" 而不是 "controller"。 - Nookaraju
@Bhargavi 是的,我检查了我的xib,因为它在以模态方式呈现时显示,所以我不认为xib有问题。而且,由于我可以推送其他视图控制器而没有问题,我不知道导航控制器怎么会有问题。这是一个非常奇怪的行为!至于你们提供的其余提示,抱歉,我只是忘记在提供的示例代码中更改变量的名称。毫无疑问,我没有将我的控制器称为'MySecondViewController'。 - Yonic Surny
显示剩余2条评论
2个回答

1

大家注意了,我解决了问题!

原来是我使用的第三方库引起了问题。
它刚刚更新了,显然与我的实现不兼容。
我仍然不知道为什么会出现这样的错误,但是恢复到以前的版本解决了问题。
我在MySecondViewControllerviewDidLoad中初始化它。

感谢您的提示。


2
那个第三方库是什么? - Evgeni Petrov

0

请尝试这个。 问题:推入了错误的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];
}

抱歉,我刚才拼错了变量,这个在那个特定的视图控制器上不起作用,但在任何其他视图控制器上都可以工作! - Yonic Surny

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接