0
我是iphone開發新手。我在分組tableView中顯示xml解析的內容。我想禁用它上的單擊事件(我不應該可以單擊它)。由於它是分組表,它包含兩張桌子,我想禁用第一張桌子而不是第二張桌子。我該如何實現它?請幫助我。謝謝。如何禁用點擊選項或選擇iPhone中的表中的行?
我是iphone開發新手。我在分組tableView中顯示xml解析的內容。我想禁用它上的單擊事件(我不應該可以單擊它)。由於它是分組表,它包含兩張桌子,我想禁用第一張桌子而不是第二張桌子。我該如何實現它?請幫助我。謝謝。如何禁用點擊選項或選擇iPhone中的表中的行?
如果你不希望用戶能夠點擊一個表格視圖,只需使用此代碼:
- (NSIndexPath *)tableView:(UITableView *)tableView
willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
return nil;
}
使用Uitable查看委託和數據源
//#endif
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSLog(@"Returning num sections");
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"Returning num rows");
return [copyListOfItems count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (NSIndexPath *)tableView:(UITableView *)tableView
willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
return nil;
}
謝謝,其working.Since它是分組表,它包含兩個表,我想禁用第一個表,而不是第二個表。我該怎麼做? – Warrior 2010-02-13 10:16:59
分組表仍然只有一個表。看看被傳入的'indexPath'變量,它應該告訴你哪個部分被點擊(連同該行)。將if語句放入不想選擇的部分返回nil。對於另一個,按原樣返回'indexPath'。 – 2010-02-13 10:21:29
謝謝,我明白了。 – Warrior 2010-02-13 10:34:33