我有一个带有自定义 UITableViewCells 的 UITableView,大多数时候当它们被触摸时,didSelectRowAtIndexPath: 被调用,并推送了一个新视图。然而,有时当他们以某种方式被点击时(点击并按住大约一秒钟),他们将保持突出显示并且不会推动下一个视图,直到在屏幕上的其他任何地方检测到另一个点击。我尝试在 didSelectRowAtIndexPath: 中记录一条消息:并确认在这些情况下没有调用它。该方法中的代码是:
PortfolioVC *portfolioController = [self.storyboard instantiateViewControllerWithIdentifier:@"portfolioIdentifier"];
AccountInformationVC *accountController = [self.storyboard instantiateViewControllerWithIdentifier:@"accountIdentifier"];
[[Globals Variables] setIndex:indexPath.row];
if (indexPath.section == 0)
[self.navigationController pushViewController:accountController animated:YES];
if (indexPath.section == 1)
[self.navigationController pushViewController:portfolioController animated:YES];
通过将 selectedBackground 连接到包含突出显示的图像的 UIImageView,在自定义 UITableViewCell 的 xib 中设置突出显示的图像。