Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 在tableview中,无法使用pushViewController打开detailview屏幕_Objective C_Ios_Uitableview_Pushviewcontroller - Fatal编程技术网

Objective c 在tableview中,无法使用pushViewController打开detailview屏幕

Objective c 在tableview中,无法使用pushViewController打开detailview屏幕,objective-c,ios,uitableview,pushviewcontroller,Objective C,Ios,Uitableview,Pushviewcontroller,我的项目中有一个选项卡栏,每个选项卡栏都有一个tableview。 我想在单击tableview中的行时打开详细信息屏幕,如下所示。但什么也没发生。 我犯的错误在哪里。我应该如何建立一个逻辑 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { DetailScreen *detail = [[DetailScreen alloc] initWithNibNa

我的项目中有一个选项卡栏,每个选项卡栏都有一个tableview。 我想在单击tableview中的行时打开详细信息屏幕,如下所示。但什么也没发生。 我犯的错误在哪里。我应该如何建立一个逻辑

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

而是将详细推送代码移动到另一个方法并调用:

[self performSelector:@selector(myMethod:) withObject:nil]

如果您的项目是基于UtiAbarViewController的应用程序,我不认为您可以使用pushViewController导航到另一个视图,除非您的项目中有导航控制器。

单击单元格时没有发生任何事情的可能原因有很多

  • 在这个方法中放一个断点。有人叫它吗
  • 应用程序在断点处停止后,在初始化实例后,转到控制台类型
    po detail
    。确保它不是(空)
  • 还可以尝试键入
    po[self-navigationController]
    检查导航控制器是否存在
您可能没有导航控制器。如何创建tabbarcontroller?在interface builder中或通过AppDelegate的
didFinishLaunchingWithOptions:
方法中的代码

你这样做了吗

    YourViewController *yourVC = [[YourViewController alloc] initWithNibName:@"YourViewController" bundle:nil];

    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:yourVC];

    self.tabBarController.viewControllers = [NSArray arrayWithObjects:navigationController, nil];
将视图控制器(包含控制器的表视图)添加到导航控制器中,然后开始使用

DetailScreen *detail = [[DetailScreen alloc] initWithNibName:@"DetailScreen" bundle:nil];
    [self.navigationController pushViewController:detail animated:YES];
试试这个

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
     DetailScreen *detail = [[DetailScreen alloc] init];
     [self.navigationController pushViewController:detail animated:YES];
     [detail release];
}

我猜你没有导航控制器,所以

[self.navigationController pushViewController:detail animated:YES];
这是行不通的

使用


相反

我正在另一个类中创建tabbarcontroller,而不是应用程序内委托,因为tab bar屏幕不是第一个屏幕。你是否将ViewController嵌入UINavigationController?@sixeightzero我的答案有什么问题?我不明白你编辑了什么。点击上面写着:x小时前编辑的。这将向您显示所做的更改。我将语法突出显示应用于您的答案,以使其更易于阅读,并将代码与文本分开。
[self.navigationController pushViewController:detail animated:YES];
[self.view addSubview:detail.view]
[self presentModalViewController:detail animated:YES];