我正在创建一个TableView
包含 20 行的内容。我必须向偶数单元格添加单个标签,并且必须在奇数单元格中添加两个标签。当我添加所需的标签并滚动我的表格时,标签会随着我的下降而消失帮助我.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// UITableView *cell=[tableView ]
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
if(indexPath.row%2==0)
{
UILabel *cellLabel=[[UILabel alloc]initWithFrame:CGRectMake(100, 40, 40, 40)];
cellLabel.text=@"o1";
[cell addSubview:cellLabel];
[cellLabel release];
}
else
{
UILabel *cellLabel1=[[UILabel alloc]initWithFrame:CGRectMake(100, 40, 40, 40)];
cellLabel1.text=@"e1";
[cell addSubview:cellLabel1];
[cellLabel1 release];
UILabel *cellLabel2=[[UILabel alloc]initWithFrame:CGRectMake(150, 40, 40, 40)];
cellLabel2.text=@"e2";
[cell addSubview:cellLabel2];
[cellLabel2 release];
}
}