我已经阅读了有关此内容的所有相关帖子,但我仍然遇到错误:
'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (5) must be equal to the number of rows contained in that section before the update (5), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
Run Code Online (Sandbox Code Playgroud)
以下是详细信息:
在.h …
这是我的代码,用于调用包含在UINavigationController中的新视图控制器.我想在restaurantResults控制器上有一个简单的后退按钮.我的选择器似乎不起作用.我尝试过使用pop命令.这些工作是否可以使用presentViewController,而不是任何类型的推送?
很确定我的选择器现在是错的,因为它说的是self.navigationController,它可能不对.
这是我调用新视图控制器并设置后退按钮的位置:
- (void)searchBarSearchButtonClicked:(UISearchBar *)foodNearSearchBar
{
restaurantsViewController *restaurantResults = [[restaurantsViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:restaurantResults];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStyleBordered
target:nil
action:@selector(backPressed:)];
restaurantResults.navigationItem.leftBarButtonItem = backButton;
[self presentViewController:navController animated:YES completion:Nil];
}
Run Code Online (Sandbox Code Playgroud)
这是我的选择器:
-(void)backPressed: (id)sender
{
[self.navigationController popViewControllerAnimated: YES]; // or popToRoot... if required.
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
- (void)backPressed:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
};
Run Code Online (Sandbox Code Playgroud)