2013-05-10 51 views
0

我是新来的目标c,并试图找出uitableview。我添加了两个单元格到tableview,当我点击tableview的任何区域,两个单元格消失或标签被删除。我不确定。我怎样才能解决这个问题?目标c点击tableview时,单元格消失

这里是我如何添加两个单元

- (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]; 
} 

if(indexPath.row==0) 
    [email protected]"test 1"; 
else if (indexPath.row==1) 
    [email protected]"test 2"; 
// Configure the cell... 

return cell; 
} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 1; 
    } 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return 5; 
} 

我已经给出了部分和行

+0

粘贴代表以及数据源方法您的完整代码.. – user968597 2013-05-10 13:11:39

+0

没有数据源或代表。我是新来的目标C :) – 2013-05-10 13:12:27

+0

首先你需要设置你的表中的行数,然后你可以定义单元格cellForAtIndexPath – user968597 2013-05-10 13:14:09

回答

0

试试这个,

你的高亮标记文本颜色可以是白色,看上去就像消失了。将此行添加到您的cellForRow的indexpath方法并检查

[cell.textLabel setHighlightedTextColor:[UIColor blackColor]]; 

最好的问候。

+0

我试过了,没有工作 – 2013-05-10 13:26:01

相关问题