Just wonder if it's possible to have UISwitch (ON/OFF) to show/hide the UITableView. For example:
There are 3 sections (Section 0,Section 1, Section 2) - cellForRowAtIndexPath
//it is for quantity (1 row) that redirects to another controller
if (indexPath.section == 0)
{
}
//it is for UISwitch (On/Off)
else if (indexPath.section == 1)
{
NSString *cellValue1 = [mealArray objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue1;
//NSLog(cell.textLabel.text);
switchview = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
cell.accessoryView = switchview;
[(UISwitch *) cell.accessoryView addTarget: self action: @selector(checkState

forControlEvents: UIControlEventValueChanged];
}
//it is for Section 2 (if switch ON then display Section 2 otherwise hide section 2)
else
{
NSString *cellValue2 = [numberArray objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue2;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
//UISwitch Action (On/Off)
- (IBAction) checkState: (id) sender {
if (switchview.on)
{
[tableNum setHidden:NO];
[tableNum reloadData];
NSLog(@"Switched ON yeah");
}
else {
[tableNum setHidden:YES];
//[tableNum reloadData];
NSLog(@"Switched OFF yeah");
}
}
* I test NSLog and it is correct BUT I don't know why UITableView (tableNum) does not show/hide. Actually tableNum is a part of Section 0,1,2. Wonder if I have to create another UITableView for Section 2 only. I am confused.
It's similar to Settings - WIFI (ON/OFF) then display the list of SSID.
Please give me advice. Hope to hear from you soon!