我是 iPhone 开发者的新手,
我正在使用UITableView
,我想要在 LHS 上Cell
的UITableView
3 个标签和 RHS 上的 3 个标签中总共有 6 个标签
这是我的代码片段,
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 180;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
CGRect frameL;
frameL.origin.x = 10;
frameL.origin.y = 10;
frameL.size.height = 50;
frameL.size.width = 200;
CGRect frameR;
frameR.origin.x = 200;
frameR.origin.y = 10;
frameR.size.height = 40;
frameR.size.width = 180;
UILabel *AlertNameLHS = [[UILabel alloc] initWithFrame:frameL];
AlertNameLHS.font=[UIFont systemFontOfSize:16.0];
AlertNameLHS.backgroundColor=[UIColor clearColor];
AlertNameLHS.textColor=[UIColor redColor];
AlertNameLHS.text=@"Alert Name :";
[cell.contentView addSubview:AlertNameLHS];
frameL.origin.y += 60;
UILabel *AlertMonthLHS = [[UILabel alloc] initWithFrame:frameL];
AlertMonthLHS.font=[UIFont systemFontOfSize:16.0];
AlertMonthLHS.backgroundColor=[UIColor clearColor];
AlertMonthLHS.textColor=[UIColor redColor];
AlertNameLHS.text=@"Alert Month :";
[cell.contentView addSubview:AlertMonthLHS];
frameL.origin.y += 120;
UILabel *DueOnLHS = [[UILabel alloc] initWithFrame:frameL];
DueOnLHS.font=[UIFont systemFontOfSize:16.0];
AlertNameLHS.text=@"Due On :";
[cell.contentView addSubview:DueOnLHS];
AlertNameRHS = [[UILabel alloc] initWithFrame:frameR];
AlertNameRHS.backgroundColor=[UIColor greenColor];
AlertNameRHS.textColor=[UIColor redColor];
AlertNameRHS.textColor=[UIColor redColor];
AlertNameRHS.font=[UIFont systemFontOfSize:18.0];
[cell.contentView addSubview:AlertNameRHS];
frameL.origin.y += 80;
AlertMonthRHS = [[UILabel alloc] initWithFrame:frameR];
AlertMonthRHS.font=[UIFont systemFontOfSize:18.0];
[cell.contentView addSubview:AlertMonthRHS];
frameL.origin.y += 120;
DueOnRHS = [[UILabel alloc] initWithFrame:frameR];
DueOnRHS.font=[UIFont systemFontOfSize:18.0];
[cell.contentView addSubview:DueOnRHS];
}
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
AlertNameRHS.text = [Myarray objectAtIndex:indexPath.row];
return cell;
}
但我无法正确看到我的 UILabel。
任何帮助将不胜感激。
编辑 ::