我在 StoryBoard 中配置了一个单独的 TableViewController。我决定,最好以编程方式连接它,而不是使用 segues,所以,我使用这段代码来展示我的 ViewController:
UIStoryboard *aStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
NewProjectViewController *newProject = [aStoryboard instantiateViewControllerWithIdentifier:@"NewProjectViewController"];
newProject.delegate = self;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:newProject];
[self presentViewController:navController animated:YES completion:nil];
但是显示的 ViewController 是简单的 TableViewController,但我在 Storyboard 中做了一些布局。似乎是一个错误。我在帖子中附上了截图来说明问题。
已解决:
问题出在这两种方法中,它们覆盖了 StoryBoard 设计:
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 0;
}
它们没有被注释,但 UITableViewController 中的其他方法被注释了。可能,我稍后将不得不对所有 UI 进行编程,因为我只想要这个解决方案用于原型设计。感谢 MaKo 的帮助!