所以我知道这个问题已经被问过很多次了,但它似乎对我不起作用。我什么都试过了。视图控制器.h
@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
NSMutableArray *tableData;
}
@property (nonatomic, retain) NSMutableArray *tableData;
@end
视图控制器.m
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
SubTableView *secondView = [[SubTableView alloc] initWithNibName:@"SubTableView" bundle:nil];
if ([[tableData objectAtIndex:indexPath.row] isEqual:@"Campus"]) {
secondView.selected = 1;
//[subTable setTitle:[tableData objectAtIndex:indexPath.row]];
}
if ([[tableData objectAtIndex:indexPath.row] isEqualToString:@"School"]) {
secondView.selected = 2;
}
if ([[tableData objectAtIndex:indexPath.row] isEqualToString:@"Admissions"]) {
secondView.selected = 3;
//[subTable setTitle:[tableData objectAtIndex:indexPath.row]];
}
if ([[tableData objectAtIndex:indexPath.row] isEqualToString:@"Boarding"]) {
secondView.selected = 4;
}
if ([[tableData objectAtIndex:indexPath.row] isEqualToString:@"Academics"]) {
secondView.selected = 4;
}
if ([[tableData objectAtIndex:indexPath.row] isEqualToString:@"Athletics"]) {
secondView.selected = 5;
}
if ([[tableData objectAtIndex:indexPath.row] isEqualToString:@"Jobs"]) {
secondView.selected = 6;
}
if ([[tableData objectAtIndex:indexPath.row] isEqualToString:@"Donate"]) {
secondView.selected = 7;
}
[self.navigationController pushViewController:secondView animated:YES];
}
我设置了 NavigationController,尽管我不知道它是否在 Storyboard 中正确链接。我在 StoryBoard 中设置的第二个视图控制器 SubTableView 带有它自己的 .h 和 .m 控制器。我的标识符为“SubTableView”,但它拒绝推送该视图。我能想到的唯一可能的事情是没有正确链接navigationController。但是我找不到任何可以在上面使用的东西。
如果我在
[self.navigationController pushViewController:secondView animated:YES];
它会撞到它并停下来。但它不会推翻新观点。