SystemUIViewcontroller has button event. Tap on Button fire InfoTableviewController. InfoTableview has UISwitch. How to set objectForKey to Info to access UIswitch
ViewDidload of System...
- (void)viewDidLoad
{
[super viewDidLoad];
self.Infoarray = [NSMutableArray array];
Info *info = [[Info alloc]initWithNibName:@"Info" bundle:nil];
[self.Infoarray addObject:[NSDictionary dictionaryWithObjectsAndKeys:info, @"viewController", nil]];
}
SystemUIviewcontroller button event...
-(IBAction) Info_Button_Clicked:(id) sender
{
Info *info = [[Info alloc]initWithNibName:@"Info" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:info animated:YES];
[info release];
}
Here for Info TableviewController...
- (void)viewDidLoad
{
[super viewDidLoad];
self.Soundarray = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
@"Sounds", @"labelKey",
self.SoundsswitchCtl, @"viewKey",
nil],nil];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = nil;
if ([indexPath section] == 0)
{
static NSString *kDisplayCell_ID = @"DisplayCellID";
cell = [self.tableView dequeueReusableCellWithIdentifier: kDisplayCell_ID];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: kDisplayCell_ID] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
else
{
// the cell is being recycled, remove old embedded controls
UIView *viewToRemove = nil;
viewToRemove = [cell.contentView viewWithTag:1];
if (viewToRemove)
[viewToRemove removeFromSuperview];
}
cell.textLabel.text = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"labelKey"];
UIControl *control = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"viewKey"];
[cell.contentView addSubview:control];
return cell;
}
}
- (UISwitch *)SoundsswitchCtl
{
if (SoundsswitchCtl == nil)
{
CGRect frame = CGRectMake(198.0, 12.0, 94.0, 27.0);
SoundsswitchCtl = [[UISwitch alloc] initWithFrame:frame];
[SoundsswitchCtl addTarget:self action:@selector(switch_Sounds:) forControlEvents:UIControlEventValueChanged];
// in case the parent view draws with a custom color or gradient, use a transparent color
SoundsswitchCtl.backgroundColor = [UIColor clearColor];
[SoundsswitchCtl setAccessibilityLabel:NSLocalizedString(@"StandardSwitch", @"")];
SoundsswitchCtl.tag = 1; // tag this view for later so we can remove it from recycled table cells
}
return SoundsswitchCtl;
}