2011-08-01 3 views
0

私は以前に見たことのないテーブルセルに奇妙な問題がありました。私はテーブルをスクロールすると、お互いに出血しています。たとえば、今、私は、最初のセクションに "デバイス"というセルがあり、2番目のセクションには "Hi"と書かれ、3番目のセクションには空白セルがいくつかあります。スクロールすると、「デバイス」が「ハイ」の上に表示されることがあります(両方のラベルが表示されていて、オーバーレイしています(背景色がはっきりしています)。間違っているのかを把握しようとしているが、何も動いていないようにみえテーブルセルが互いにブリードアウト

をここに私のテーブルビューコントローラの関連セクションされています。。

- (id)initWithDeviceCoordinator:(DeviceCoordinator*)dev_con 
{ 
    self = [super initWithStyle:UITableViewStyleGrouped]; 
    if (self) { 
     device_coordinator = dev_con; 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
} 

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    // Return the number of rows in the section. 
    if (section == 0 || section == 3) return 1; 
    else if (section == 1) return 8; 
    else if (section == 2) return 2; 
} 

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

    if (indexPath.section == 0) cell.textLabel.text = [device_coordinator getDeviceName]; 
    else if (indexPath.section == 1) 
    { 
     if (indexPath.row == [[device_coordinator getChannelList] count]) 
     { 
      cell.textLabel.text = @"Add new channel"; 
      return cell; 
     } 
     cell.textLabel.text = @"HI"; 
     return cell; 
    } 
    return cell; 
} 

クラスの他の機能のすべてが、XCodeのデフォルトです

答えて

0

問題が見つかりました。これは、この行をした:

NSString *CellIdentifier = [NSString stringWithFormat:@"Cell %d_%d",indexPath.section,indexPath.row]; 
+1

問題、また解決策はありません。

static NSString *CellIdentifier = @"Cell"; 

は、この固定すべてのものに変更します。 – InsertWittyName

1

cell.textLabel.text = nilを先頭に設定する必要があります。そうしないと、セルが再利用されたときにテキストが間違った場所に表示されます(saあなたが見たことのないイド)オーバーラップするラベルに関しては、貼り付けたコードがその原因になるとは思わない。カスタムセルを使用していますか?

関連する問題