iphone - 调用相同的 View Controller 但需要不同的操作

标签 iphone uitableview uiviewcontroller xcode4.2 didselectrowatindexpath

我有一个 View Controller ,其中包含 UITableView 中的类别列表。我将此 View Controller 插入其他三个 View Controller 中。因此,当调用 tableView 时,就会应用相同的功能,但我不希望发生这种情况.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ 
self.index = indexPath;
[retrieveName getItemName:[self.arrayForCategories objectAtIndex:indexPath.row]];
[self dismissModalViewControllerAnimated:YES];
[tableView reloadData];
}

此方法仅在从一个 View Controller 调用时才有效。有什么想法吗?

最佳答案

在您要推送的 View Controller 中放置一个属性,该属性决定了它在被选择时应该执行的操作。让插入它的 View Controller 设置该属性。检查您所展示的方法开始处的属性值。

关于iphone - 调用相同的 View Controller 但需要不同的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10915334/

相关文章:

ios - 带有 UTF-8 字符串的 UITableView header ?

iphone - 我应该使用什么类型的 iPhone 应用程序文件?

ios - 自定义单元格 TextView 重复

ios - 由于 AVPlayer 和观察者的初始化失败导致内存泄漏

swift - 自定义 UIViewControllerAnimatedTransitioning 完成后显示黑屏

iOS( swift ): Presenting View Controller Embedded in Navigation Controller

iphone - iPhone 4S 上的核心蓝牙故障?

iphone - 如何在 iPhone 上访问 safari、facebook 等应用程序的远程连接请求

iphone - iPhone 允许光传感器作为输入吗?

iphone - 当属性设置太早时 UIImageView 不显示图像