gpt4 book ai didi

iphone - 从 viewController 内的 tableview 推送 viewController 不起作用

转载 作者:行者123 更新时间:2023-11-28 17:39:30 26 4
gpt4 key购买 nike

我在将我的 View Controller 从被放入 viewController 的 tableview 中推送时遇到问题,而不是 TableViewController。

我在这里找到了解决方案的线程

pushViewController is not pushing

问题是..我已经完成了他的解决方案,但我的观点仍然没有插入。我已经通过 ctrl+drag 将我的 tableview 连接到 View Controller 并设置了数据源和委托(delegate)。在我提到的帖子中,他们说解决方案是“创建一个从 TableView 到 View Controller 的引用导出”。但我不完全知道那是什么意思。因此,对此提供帮助也很好。我关注了this tutorial显然我卡在了第 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。它不是。

根据我收集到的信息,这里的问题在于 TableView 位于 View Controller 内部,而不是“tableviewcontroller”。如果是这种情况,此方法显然有效,但如果不是,则必须采取其他一些步骤。但我不知道它们。

提前致谢。

最佳答案

听起来您的 NavigationController 设置不正确。你能发布设置它的代码吗?

关于iphone - 从 viewController 内的 tableview 推送 viewController 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8717057/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com