2010-01-12 99 views
0

在OS 3.0上,當allowSelection = NO時,無法選擇任何行並取消行高亮。如何在iPhone OS 3.0之前模擬UITableView上的allowedSelection?

在預OS 3.0,最明顯的解決方案,以禁止選擇是在willSelectRowAtIndexPath返回nil,這是的UITableViewDelegate

的一部分

但是,有兩個問題的方法:

1)這不是穩定(即不時取得一排行...)
2)這是不取消行突出顯示

任何線索?

回答

4

您應該將個人UITableViewCell上的selectionStyle設置爲您不希望被選爲UITableViewCellSelectionStyleNone。對於那些你想要選擇的,UITableViewCellSelectionStyleBlue。基本上:

- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    //... 
    cell.selectionStyle = (canSelectRow ? UITableViewCellSelectionStyleBlue : UITableViewCellSelectionStyleNone); 
    return cell; 
} 
1

要取消行突出顯示,您可以將單元格的selectionStyle設置爲UITableViewCellSelectionStyleNone。

從willSelectRowAtIndexPath返回nil一直爲我工作...