2012-02-09 3 views
0

Я анализирую данные json и присваиваю их в моей таблице view cell.where в первой строке ячейки tableview .im, назначая статические данные (зеленый текст) .if i прокручивает мой табличный вид назначенные данные в первой таблице вид клеток становится overlaped в моем 6 и 7 TableView cell.below является экран shotand code.could у ребят помочь мнеданные, которые перекрываются в ячейке tableview

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; 

} 
if(indexPath.row == 0) 
{ 

    [email protected]"Pollenprognosen"; 
    cell.textLabel.textColor=[UIColor greenColor]; 
    [email protected]"se dagens pollenprognos"; 
    cell.detailTextLabel.font=[UIFont systemFontOfSize:([UIFont systemFontSize]-2)]; 

    return cell; 
} 
else 
{ 
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; 
cell.textLabel.text=[story objectAtIndex:indexPath.row]; 
    return cell; 
} 
} 

enter image description here

ответ

3

Я думаю, это потому, что клетка повторно , Используйте этот код вместо этого:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 

    static NSString *CellIdentifier = @"Cell"; 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; 

    } 
    if(indexPath.row == 0) 
    { 

     [email protected]"Pollenprognosen"; 
     cell.textLabel.textColor=[UIColor greenColor]; 
     [email protected]"se dagens pollenprognos"; 
     cell.detailTextLabel.font=[UIFont systemFontOfSize:([UIFont systemFontSize]-2)]; 
cell.accessoryType=UITableViewCellAccessoryNone; 
     return cell; 
    } 
    else 
    { 

    cell.textLabel.text=[story objectAtIndex:indexPath.row]; 
cell.textLabel.textColor=[UIColor blackColor]; 
cell.detailTextLabel.text=nil; 
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; 
     return cell; 

    } 
    } 
+0

чувак, который полностью сработал ... спасибо тонну – kingston

+0

Без проблем, рад помочь человеку SO: er. –

+0

Чувак, я сталкиваюсь с той же проблемой наложения. Но на этот раз дело доходит до изображения. Я отправил его как отдельный вопрос, мог бы помочь мне – kingston

2

Просто сделайте else следующим образом.

else 
{ 
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; 
    cell.textLabel.text=[NSString stringWithFormat:@"Cell %d",indexPath.row]; 

    cell.textLabel.textColor=[UIColor blackColor]; 
    [email protected]""; 

    return cell; 
} 
Смежные вопросы