Iphone 如何在两个部分中激活tableView DidSelectRowatineXpath?

Iphone 如何在两个部分中激活tableView DidSelectRowatineXpath?,iphone,ios,xcode,Iphone,Ios,Xcode,我有一个UItableView,分为两个部分 如何管理tableView didSelectRowAtIndexPath方法 对于第1节,方法正在运行,但是对于第2节,我不知道如何实现 谢谢 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 简单地说: -(void)tableView:(UITableView *)tableView didSelectRow

我有一个UItableView,分为两个部分

如何管理tableView didSelectRowAtIndexPath方法

对于第1节,方法正在运行,但是对于第2节,我不知道如何实现

谢谢

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
简单地说:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 if(indexPath.section == 0) {
   //Your code for Section 1 with the index 0
 } else {
   //Your code for Section 2 with the index 1
 } 
}
简单地说:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 if(indexPath.section == 0) {
   //Your code for Section 1 with the index 0
 } else {
   //Your code for Section 2 with the index 1
 } 
}

只需使用UITableView的委托方法:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
您可以使用以下代码在部分中进行区分:

if (indexPath.section == 0) 
if (indexPath.section == 1)

..upto n depends on number of sections in your TableView.

只需使用UITableView的委托方法:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
您可以使用以下代码在部分中进行区分:

if (indexPath.section == 0) 
if (indexPath.section == 1)

..upto n depends on number of sections in your TableView.