Uitableview UINavigationBar中的“后退”按钮正在打开当前视图本身

Uitableview UINavigationBar中的“后退”按钮正在打开当前视图本身,uitableview,uisearchbar,xcode-storyboard,Uitableview,Uisearchbar,Xcode Storyboard,(1) 。我刚刚在情节提要的UITableView中添加了UISearchBar。当我从默认UITableView中单击单元格时,它会转到详细信息视图,我可以通过单击导航栏中的“上一步”按钮返回默认UITableView。这是正确的 (2) 。问题是,当我从searchDisplayController.searchResultsTableView中单击单元格时,它会转到详细信息视图,而我无法通过单击导航栏中的“上一步”按钮返回默认UITableView。程序以以下错误结束 Terminatin

(1) 。我刚刚在情节提要的UITableView中添加了UISearchBar。当我从默认UITableView中单击单元格时,它会转到详细信息视图,我可以通过单击导航栏中的“上一步”按钮返回默认UITableView。这是正确的

(2) 。问题是,当我从searchDisplayController.searchResultsTableView中单击单元格时,它会转到详细信息视图,而我无法通过单击导航栏中的“上一步”按钮返回默认UITableView。程序以以下错误结束

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't add self as subview'

您可能会注意到“后退”按钮标题显示了案例(2)中的视图标题,无法正确返回到上一个视图。我该如何解决这个问题?谢谢。

我通过跟踪控制台中的segue操作发现了问题。我不需要在单元格选择中执行自己的segue操作。它使应用程序打开详细信息视图两次。这就是为什么“后退”按钮会返回其自身的详细视图。通过删除[self-PerformsgueWithIdentifier],它现在可以工作了

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   if (tableView == self.searchDisplayController.searchResultsTableView) {
       [self performSegueWithIdentifier: @"segueSongsToSong" sender: self];
   }
}

UITableView(BooksViewController with title "Books")
Search Results
Item 1(Selected)
Item 3

DetailsView(BookDetailsViewController)
Item 1(Back button in navigation bar)
Item 1(View Title)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   if (tableView == self.searchDisplayController.searchResultsTableView) {
       [self performSegueWithIdentifier: @"segueSongsToSong" sender: self];
   }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}