2013-02-27 32 views
0

我的问题如果行返回5然后UITableView显示0到5的索引,但我们想打印3到5的任何逻辑' //创建单元格标识符 static NSString * CellIdentifier = @ “CellIdentifier”;我可以打印可用的customzie行

// Create the cell if cells are available with same cell identifier 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

// If there are no cells available, allocate a new one with Default style 
if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
} 

cell.textLabel.text = [[no objectAtIndex:indexPath.row]valueForKey:@"name"]; 
// Configure cell... 

我可以打印出值定制范围

回答

0

您的解决方案是这样的,它是可以正常使用:在.M

在.H

Bool drawCell;

- (void)viewDidLoad 
{ 
drawCell=NO; 
}  
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{   
UITableViewCell *cell = nil; 
if(indexPath.row==3) 
{ 
drawCell=YES; 
} 
if(drawCell) 
{ 
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; 
cell.textLabel.text = [[no objectAtIndex:indexPath.row]valueForKey:@"name"]; 
} 
else 
{ 
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; 
    cell.frame=CGRectMake(0, 0, 0, 0); 
} 

return cell; 
} 
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
if (drawCell) { 
    return 100.0f; 
} else { 
    return 0.0f; 
} 
} 
+0

thnx亲爱的帮助我 – 2013-03-08 12:16:02