我有一個問題推動我的視圖控制器從一個tableview被放入viewController,而不是一個TableViewController。從viewview裏面的viewController不工作推動viewController
我發現一個線程在這裏的這裏
pushViewController is not pushing
解決的問題是..我做了他的解決辦法,我的看法仍然沒有推。我已經連接我的桌面視圖通過CTRL +拖動到視圖控制器並設置數據源和委託。在我提到的文章中,他們說解決方案是'從tableview創建一個引用插座到視圖控制器。'但我不完全知道這意味着什麼。所以,這樣做的幫助也會很好。我跟着this tutorial,明顯地卡在第9步。
的代碼不會觸發線是
[self.navigationController pushViewController:facility animated:YES];
我的代碼如下...
viewTable方法
- (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」。如果是這種情況,這種方法顯然是有效的,但是如果不是這樣的話,必須採取其他一些步驟,但我不知道它們。
在此先感謝。
我的錯誤..導航控制器從來沒有建立(自從我參與這個項目以來,它已經有一段時間了)。我一直在使用segues而不是導航控制器來處理所有的視圖轉換。我切換到segue設置,它工作得很好。我想現在我的問題是......這會影響表和數據傳遞等任何東西嗎?使用segues或導航控制器有什麼區別? – 2012-01-03 19:19:49
從我所瞭解的情況來看,您仍然必須像以前一樣設置數據並將其傳遞到新的ViewController(設施)。 – 2012-01-03 19:25:54
謝謝安德魯。只要功能上基本一樣,一切都很好。 – 2012-01-03 19:26:04