I'm having problems in the iPad view, I'm trying to make a table where each cell will be made up of textLabel
and a button UIButton
, when I try it on an iphone the view goes well, but when I I try with an iPad it comes out in the following way:
The code I have is the following:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *simpleTable = [NSString stringWithFormat:@"simpleTableIdentifier%ld", (long)indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTable];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTable];
}
Centro_DTO *cen_datos = [[Centro_DTO alloc] init];
cen_datos = [self.computersCentros objectAtIndex:indexPath.row];
NSString *currentL = ([Global sharedMySingleton].test);
if ([currentL isEqualToString:@"es"]) {
cell.textLabel.text = cen_datos.nombreES;
} else if ([currentL isEqualToString:@"ca-ES"]) {
cell.textLabel.text = cen_datos.nombreCA;
} else if ([currentL isEqualToString:@"en"]) {
cell.textLabel.text = cen_datos.nombreEN;
}
cell.textLabel.textColor = [UIColor colorWithRed:(0/255.0) green:(44/255.0) blue:(82/255.0) alpha:1];
cell.textLabel.font = [UIFont systemFontOfSize:13.0];
cell.accessoryType = UITableViewCellAccessoryNone;
UIButton *centroActivo = [[UIButton alloc] init];
centroActivo.highlighted = NO;
int orientation = [[UIApplication sharedApplication]statusBarOrientation];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad || (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && orientation != UIDeviceOrientationPortrait)) {
centroActivo.frame = CGRectMake(350.0, 15.0f, 20.0f, 20.0f);
} else {
centroActivo.frame = CGRectMake(290.0, 15.0f, 20.0f, 20.0f);
}
centroActivo.tag = indexPath.row;
[centroActivo setImage:[UIImage imageNamed:@"checkbox_checked.png"] forState:UIControlStateSelected];
[centroActivo setImage:[UIImage imageNamed:@"checkbox_unchecked.png"] forState:UIControlStateNormal];
[centroActivo addTarget:self action:@selector(checkboxSelected:) forControlEvents:UIControlEventTouchUpInside];
if (cen_datos.activo == 1) {
[centroActivo setSelected:YES];
} else {
[centroActivo setSelected:NO];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.contentView addSubview:centroActivo];
return cell;
}
and what I want is for it to look like this on the ipad:
Any suggestions on what it can be?
PS: I am quite new with the development in Objective- c