Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.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

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
Iphone 从viewController内部的tableview中推送viewController不工作_Iphone_Objective C_Ios_Xcode - Fatal编程技术网

Iphone 从viewController内部的tableview中推送viewController不工作

Iphone 从viewController内部的tableview中推送viewController不工作,iphone,objective-c,ios,xcode,Iphone,Objective C,Ios,Xcode,将视图控制器从已放入viewController而不是TableViewController的tableview中推入时出现问题 我在这里找到了一条线索和一个解决方案 问题是。。我已经完成了他的解决方案,但我的观点仍然没有说服力。我已经通过ctrl+drag将tableview连接到视图控制器,并设置了数据源和委托。在我提到的帖子中,他们说解决方案是“创建一个从tableview到view控制器的引用出口”,但我不知道这到底意味着什么。所以这方面的帮助也会很好。很明显,我已经遵循了第9步 未触

将视图控制器从已放入viewController而不是TableViewController的tableview中推入时出现问题

我在这里找到了一条线索和一个解决方案

问题是。。我已经完成了他的解决方案,但我的观点仍然没有说服力。我已经通过ctrl+drag将tableview连接到视图控制器,并设置了数据源和委托。在我提到的帖子中,他们说解决方案是“创建一个从tableview到view控制器的引用出口”,但我不知道这到底意味着什么。所以这方面的帮助也会很好。很明显,我已经遵循了第9步

未触发的代码行为

[self.navigationController pushViewController:facility animated:YES];
我的代码如下

视图表方法

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{   
 NSLog(@"list Size: %@",list);
    return [list count];
}

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
    static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if(cell == nil){
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
CustomerListData *customer = [self.list objectAtIndex:indexPath.row];
cell.textLabel.text = customer.facilityName;

// cell.textLabel.text = @"Detail";
return cell;
}

-(void)setValue:(NSMutableArray*)array
{ 
//NSMutableArray *newArray = [[NSMutableArray alloc] init];
list = array;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

FacilityMissionListViewController *facility = [self.storyboard instantiateViewControllerWithIdentifier:@"facilityMissionList"];
[self.navigationController pushViewController:facility animated:YES]; 
//UINavigationController* navController = self.navigationController;
}
最后一个注释掉的行用于检查navigationcontroller是否为null。事实并非如此

从我收集的信息来看,这里的问题在于,表视图位于视图控制器内部,而不是“tableviewcontroller”。如果是这种情况,此方法显然有效,但如果不是,则必须采取其他一些步骤。。但我不认识他们

提前感谢。

放一张:

NSLog(@"%@", self.navigationController);
在DidSelectRowatineXpath方法中,您将看到是否正在调用该方法,以及navigationController是否为nil。这可能是其中之一


否则,请确保FacilityMissionListViewController也不是零。

听起来您的导航控制器设置不正确。您可以发布设置它的代码吗?

Ok,单击按钮确实会调用该方法,但self.navigationcontroller实际上是空的。显然,另一种检查方法是不准确的。那我该怎么办?我的错。。导航控制器从未设置过(自从我参与这个项目以来已经有一段时间了)。在我所有的视图转换中,我一直使用segues而不是nav控制器。我切换到segue设置,效果很好。我想现在我的问题是。。这会对表和数据传递等产生影响吗?使用segues或导航控制器之间有什么区别吗?据我所知,您仍然需要像以前一样设置并将数据传递到新的ViewController(设备)。谢谢Andrew。只要在功能上它基本上是一样的一切都好。