I have found a multitude of questions asking almost what I am after, but have been as of yet unable to implement my own solution.
I have 2 sections in my UITableViewController, and everything works fairly well so far. I have an AlarmEnabled UISwitch, and an AlarmDate cell, which pulls up a UIActionSheet so that one can choose the fire date, etc. I am attempting to disable/grey-out the AlarmDate cell (cell 0) when one negates the AlarmEnabled UISwitch in "real time". This does work, but only if I a) Negate UISwitch b) Exit view by the Cancel/Save UIButton c) Re-enter the view.
I have so far tried the tableView:reloadRowsAtIndexPath: method as follows:
NSIndexPath *tempIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
NSArray *tempIndexPathArray = [[NSArray alloc] initWithObjects:tempIndexPath, nil];
[self.tableView reloadRowsAtIndexPaths:tempIndexPathArray withRowAnimation:UITableViewRowAnimationNone];
[tempIndexPathArray release];
Perhaps due to my on-off relationship with iOS programming, I just misunderstand where that code should be placed (currently placed within the selector for the AlarmEnabled UISwitch accessory), but it doesn't do what i'm after (but sounds like it should if used correctly).
I thought i'd try to increase my cognition and try something like the following in the selector for the UISwitch,
#define NOT(a) !a
....
UITableViewCell *tempCellAlarmDate = [self.tableViewController.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
tempCellAlarmDate.userInteractionEnabled = NOT(tempCellAlarmDate.userInteractionEnabled);
// forget transparency for now.
//tempCellAlarmDate.alpha = 0.0;
.. but the briskly-trotting rodent powering the dynamo in my skull does not approve of this code, and thus my dream of real-time userInteractionEnabled toggling goes unrealised.
Any advice is appreciated :-)
Thanks
sc.
I'm missing where you are calling the setEnabled: method on the cell. Or are you disabling it using some other method? In my experience, setEnabled: NO disables a cell in real time, and setEnabled: YES brings it back. Perhaps I'm missing something?
#define NOT(a) !a
- are you kidding - Sulthan 2012-04-05 17:54