2010-12-01 65 views
0

我有一個奇怪的問題,我的UITableView。我希望表格中的所有單元格都是可選的,這樣如果選擇一個單元格,就會執行相應的操作。我的表格中的所有單元格當前都可以從第0行的單元格中選擇(單元格出現在表格的頂部)。這個單元格是不可選擇的,即使它已被設置爲允許選擇。有任何想法嗎?iPhone編碼:與UITableView選擇問題


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
tableView.allowsSelection = YES; 
static NSString *SettingsTableID = @"SettingsTableID"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SettingsTableID]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 
            reuseIdentifier: SettingsTableID] autorelease]; 
} 
cell.textLabel.text = [tableHeadingsArray objectAtIndex:row]; 
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
return cell; 

}


非常感謝。

+0

可以üPLZ後你的didSelectRowAtIndexPath:代碼??? – KingofBliss 2010-12-01 17:27:53

回答

0

對不起,我是愚蠢的。 :)這段代碼在我的ViewController子類中。我從一個例子中複製了這個類,並忘記在使用它之前仔細檢查它。

-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
NSUInteger row = [indexPath row]; 
if (row == 0) 
    return nil; 
return indexPath; 

}

刪除這已解決了這一問題。

乾杯。