Advertisement
redribben

collapse

Jan 30th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  2. {
  3.     static NSString *CellIdentifier = @"Cell";
  4.     BMOptionCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  5.    
  6.     cell.cellSwitch.UDKey = [(BMSettings *)[tableCellArray objectAtIndex:indexPath.row] SKey];
  7.    
  8.     [cell.cellSwitch addTarget:self action:@selector(switchUD:) forControlEvents:UIControlEventValueChanged];
  9.    
  10.     // Display cell in the table cell
  11.     BMOptionCell *setting = [tableCellArray objectAtIndex:indexPath.row];
  12.    
  13.     cell.cellLabel.text = setting.name;
  14.    
  15.     NSUserDefaults *uDefaults = [NSUserDefaults standardUserDefaults];
  16.     NSLog(@"%@ is the cell.cellSwitch.UDKey String", cell.cellSwitch.UDKey);
  17.     if ([[uDefaults stringForKey:cell.cellSwitch.UDKey] isEqualToString:@"ON"]) {
  18.         NSLog(@"State is ON in this NSUserDefaults");
  19.         cell.cellSwitch.on = YES;
  20.     }
  21.     else if ([[uDefaults stringForKey:cell.cellSwitch.UDKey] isEqualToString:@"OFF"]) {
  22.         NSLog(@"State is OFF in this NSUserDefaults");
  23.         cell.cellSwitch.on = NO;
  24.     }
  25.         else {
  26.         NSLog(@"Something went wrong with setting the switch");
  27.     }
  28.    
  29.     // Assign our own background image for the cell
  30.     UIImage *background = [self cellBackgroundForRowAtIndexPath:indexPath];
  31.    
  32.     UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:background];
  33.     cellBackgroundView.image = background;
  34.     cell.backgroundView = cellBackgroundView;
  35.    
  36.     cell.cellView.backgroundColor = [UIColor colorWithPatternImage:background];
  37.    
  38.     cell.infoView.frame = CGRectMake(cell.infoView.frame.origin.x, cell.infoView.frame.origin.y, cell.infoView.frame.size.width, 0);
  39.    
  40.     return cell;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement