0

シンプルな UITableView を使用し、セパレーターを画像として使用しています。テーブルが最初にロードされたときは問題なく見えますが、ユーザーが上にスクロールして離れると、セパレーターの画像が消えます。ユーザーが下にスクロールして離れると、再び線が表示されます。

これを解決する方法を教えてください。

- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:    (NSIndexPath *)indexPath
{
   static NSString *CellID=@"Cell"
   MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

if (cell == nil)
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SwitchCellIdentifier];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    UIImageview *aSwitch = [[UIImageview alloc] initWithImage:[UIImage imageNamed:@"divider.png"]];
    separator.frame = CGRectMake(0,50,320,1);
    [cell.contentView addSubview:seperator];

}
..........    
4

2 に答える 2

0

separatorテーブル内のすべてのセパレーターに対して1 つのインスタンスを使用しようとしていますか? ビューは単一のスーパービューにしか追加できないため、これは機能しません。再利用プール内のセルごとに新しいセパレーターを初期化する必要があります。

于 2013-05-15T01:18:02.140 に答える