2013-05-10 55 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

相關問題