I'm populating UITableViewController
with data and some of created cells need to be disabled and some other are left with detail accessory button. What I need to get done is to disable those with detail accessory (their selection) but leave this detail button active to get some info.
Expanding on the answer given by mobiletest, I have done something similar.
I created the cells with the disclosure indicator type for the accessory
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
In the UITableViewControllerDelegate method
- (UITableViewCell*) tableView: (UITableView*) tableView cellForRowAtIndexPath: (NSIndexPath*) indexPath
I created a custom button on each cell. In order to identify exactly which button on which cell is selected, this answer on SO helped me.
You can choose not to change the selectionStyle of the cell, but I suggest you do, so that the app looks better, and the cell will not show anything to suggest that the cell can be selected, which will make it easier in terms of usability for the user.
Alternatively, you can have a check in the method
- (void) tableView: (UITableView*) tableView didSelectRowAtIndexPath: (NSIndexPath*) indexPath
You can get the cell selected and check the accessoryType of the cell and place your logic.
UITableViewCell *cell = (UITableViewCell *)[(UITableView *)self.view cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryDisclosureIndicator)
{
//Your logic here
}
But this will mean that your entire cell is made to selectable (if not the disclosure button will not work if selected), and in this case it will mean that you cannot customize your disclosure button. Also, since your entire cell is selectable, your logic will also run as long as the user clicks on the cell, which, judging from the question, does not sound like the feature you want, but I may be wrong. :)
See which works for you. Hope this helps!