我创建其中包含20个rows.I一个TableView
有一个标签添加到偶数细胞,我必须在奇cells.When添加两个标签,我添加所需的标签和滚动我餐桌上的标签让我失望,因为我下去帮助我。标签上没有显示的tableView细胞
- (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)];
[email protected]"o1";
[cell addSubview:cellLabel];
[cellLabel release];
}
else
{
UILabel *cellLabel1=[[UILabel alloc]initWithFrame:CGRectMake(100, 40, 40, 40)];
[email protected]"e1";
[cell addSubview:cellLabel1];
[cellLabel1 release];
UILabel *cellLabel2=[[UILabel alloc]initWithFrame:CGRectMake(150, 40, 40, 40)];
[email protected]"e2";
[cell addSubview:cellLabel2];
[cellLabel2 release];
}
}
的可能重复的[在的UITableViewCell文本丢失时向下滚动(http://stackoverflow.com/questions/1432143/text-in-uitableviewcell -missing-时,向下滚屏) – rishi
您需要tag'属性添加到''每一个的UILabel – iNoob
http://www.theappcodeblog.com/2011/02/24/table-view-tutorial-part-4-customizing -a-table-cell/ –