vendredi 6 mars 2015

detailTextLabel not showing until selecting a row

hey guys I have a problem with a uitableviewcell, the problem is by the detailTextLabel, which I have set to right detail in the storyboard. When the view appears everything except the strings of the detailTextLabel shows up. So now to the real strange part, when I select a row suddenly the text appears.


So here's my code for the cellAtIndexPathRow: method:



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0 || indexPath.section ==2) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"lastCell" forIndexPath:indexPath];
cell.textLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:UITableViewAutomaticDimension];
switch (indexPath.section) {
case 0:
_datePicker = [UIDatePicker new];
_datePicker.datePickerMode = UIDatePickerModeTime;
[cell addSubview:_datePicker];
break;
case 2:
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.textLabel.textColor = [UIColor redColor];
cell.textLabel.text = NSLocalizedString(@"Delete alarm", nil);
break;
}
return cell;
} else {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
cell.textLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:UITableViewAutomaticDimension];
cell.detailTextLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:UITableViewAutomaticDimension];
//cell.detailTextLabel.text = @"";
switch (indexPath.row) {
case 0:
cell.textLabel.text = NSLocalizedString(@"Repeat", nil);
cell.detailTextLabel.text = @"Mo. Tu. We.";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
break;
case 1:
cell.textLabel.text = NSLocalizedString(@"Cycles", nil);
cell.detailTextLabel.text = @"7";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
break;
case 2:
cell.textLabel.text = NSLocalizedString(@"Description", nil);
cell.detailTextLabel.text = @"Alarm";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
break;
case 3:
cell.textLabel.text = NSLocalizedString(@"Sound", nil);
cell.detailTextLabel.text = @"Radar";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
break;
case 4:
_snoozeSwitch = [UISwitch new];
[_snoozeSwitch setOn:YES];
[_snoozeSwitch addTarget:self
action:@selector(updateSwitch:)
forControlEvents:UIControlEventValueChanged];
cell.accessoryView = _snoozeSwitch;
cell.textLabel.text = NSLocalizedString(@"Snooze", nil);
cell.detailTextLabel.text = @"";
break;
default:
NSLog(@"%s:BUG!",__PRETTY_FUNCTION__);
}
return cell;
}
}


So I hope for ur help thanks guys




Aucun commentaire:

Enregistrer un commentaire