Реализация следующих методов,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [self getCellContentView:CellIdentifier];
}
UILabel *lblManuName1 = (UILabel *)[cell viewWithTag:1];
UILabel *lblManuName2 = (UILabel *)[cell viewWithTag:2];
UILabel *lblCmpnyName1 = (UILabel *)[cell viewWithTag:3];
UILabel *lblCmpnyName2 = (UILabel *)[cell viewWithTag:4];
lblManuName1.text = @"Lbl 1" ;
lblManuName2.text = @"Lbl 2" ;
lblManuName2.text = @"Lbl 3" ;
lblCmpnyName2.text = @"Lbl 4" ;
return cell;
}
- (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier {
CGRect CellFrame = CGRectMake(0, 0, 250, 30);
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
CGRect LabelManuName1Frame;
CGRect LabelManuName2Frame ;
CGRect LabelCmpnyName1Frame;
CGRect LabelCmpnyName2Frame;
LabelManuName1Frame = CGRectMake(10, 5, 75, 15);
LabelManuName2Frame = CGRectMake(59, 5, 205, 15);
LabelCmpnyName1Frame = CGRectMake(10, 22, 100, 15);
LabelCmpnyName2Frame = CGRectMake(59, 22, 205, 15);
if (orientation == UIInterfaceOrientationLandscapeLeft ||
orientation == UIInterfaceOrientationLandscapeRight) {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//LabelManuName1Frame = CGRectMake(10, 13.5, 180, 15);
//LabelManuName2Frame = CGRectMake(59, 13.5, 580, 15);
LabelManuName1Frame = CGRectMake(10, 5, 70, 30);
LabelManuName2Frame = CGRectMake(80, 5, 350, 30);
//LabelCmpnyName1Frame = CGRectMake(410, 13.5, 235, 15);
//LabelCmpnyName2Frame = CGRectMake(459, 13.5, 580, 15);
LabelCmpnyName1Frame = CGRectMake(435, 5, 70, 30);
LabelCmpnyName2Frame = CGRectMake(505, 5, 350, 30);
}else{
LabelManuName1Frame = CGRectMake(10, 5, 75, 15);
LabelManuName2Frame = CGRectMake(59, 5, 370, 15);
LabelCmpnyName1Frame = CGRectMake(10, 22, 130, 15);
LabelCmpnyName2Frame = CGRectMake(59, 22, 370, 15);
}
} else {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//LabelManuName1Frame = CGRectMake(10, 13.5, 180, 15);
//LabelManuName2Frame = CGRectMake(59, 13.5, 300, 15);
LabelManuName1Frame = CGRectMake(10, 5, 70, 30);
LabelManuName2Frame = CGRectMake(80, 5, 250, 30);
//LabelCmpnyName1Frame = CGRectMake(370, 13.5, 205, 15);
//LabelCmpnyName2Frame = CGRectMake(419, 13.5, 200, 15);
LabelCmpnyName1Frame = CGRectMake(330, 5, 70, 30);
LabelCmpnyName2Frame = CGRectMake(400, 5, 250, 30);
}else {
LabelManuName1Frame = CGRectMake(10, 5, 75, 15);
LabelManuName2Frame = CGRectMake(59, 5, 205, 15);
LabelCmpnyName1Frame = CGRectMake(10, 22, 100, 15);
//Increse width of LabelCmpnyName2Frame
LabelCmpnyName2Frame = CGRectMake(59, 22, 205, 15);
}
}
UILabel *lblTemp;
UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CellFrame reuseIdentifier:cellIdentifier] autorelease];
//Initialize Label with tag 3.
lblTemp = [[UILabel alloc] initWithFrame:LabelManuName1Frame];
lblTemp.tag = 1;
//lblTemp.font = [UIFont fontNamesForFamilyName:@"Arial"];
lblTemp.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
lblTemp.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:lblTemp];
[lblTemp release];
//Initialize Label with tag 4.
lblTemp = [[UILabel alloc] initWithFrame:LabelManuName2Frame];
lblTemp.tag = 2;
//lblTemp.font = [UIFont fontNamesForFamilyName:@"Arial"];
lblTemp.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
lblTemp.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:lblTemp];
[lblTemp release];
//Initialize Label with tag 5.
lblTemp = [[UILabel alloc] initWithFrame:LabelCmpnyName1Frame];
lblTemp.tag = 3;
//lblTemp.font = [UIFont fontNamesForFamilyName:@"Arial"];
lblTemp.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
lblTemp.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:lblTemp];
[lblTemp release];
//Initialize Label with tag 6.
lblTemp = [[UILabel alloc] initWithFrame:LabelCmpnyName2Frame];
lblTemp.tag = 4;
//lblTemp.font = [UIFont fontNamesForFamilyName:@"Arial"];
lblTemp.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
lblTemp.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:lblTemp];
[lblTemp release];
return cell;
}