我有一個包含2個部分的分組表格視圖。部分編號1是隱藏的,當您點擊部分標題時部分將打開。但是當我想通過點擊第1節中的單元格打開視圖時,我需要雙擊才能打開它。但在第0節中,我只需要1次點擊。 我基於Apple教程中的開放/關閉部分。必須在uitableviewcell中雙擊才能打開視圖
didSelectRowAtIndexPath方法不會在單元格中註冊第一個水龍頭。
的方法看起來是這樣的:
-(void)tableview:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if(indexPath.section == 0 && indexPath.row == 0)
[self.navigationController pushViewController:trainingController animated:YES];
else if(indexPath.section == 1 && indexPath.row ==0)
[self.navigationController pushViewController:newsController animated:YES];
}
這是僞代碼,所以可能不是一個工作代碼。
很明顯,如果方法在第一部分和第一部分的第二部分中的反應是合乎邏輯的,那就是它爲它設置的委託自己。無論如何,該類繼承自UITableViewController而不是UIViewController。 – lagos 2012-04-27 10:19:31