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

}

if(cell.height == 22)
{
   /// here i am setting frame for uiimageview
}

しかし、スクロール中に20行のうち1行だけセパレーター画像が消えます。

このようにロードされる理由を教えてください。

4

2 に答える 2

1

セパレーターUIImageをセルの境界外に配置cell.clipsToBounds = NO;し、セパレーター画像を表示するように設定した場合、次のセルを描画するとセパレーター画像が非表示になることがあります。

セルが画面に描画されているため、セルの z-index を制御することはできません。スクロールしている場所 (下から上、または上から下) によって異なります。

それが本当に問題である場合は、セルのフレーム内に仕切りを配置するか、区切りが十分に薄い場合は次のように使用できます。

[TableView setSeparatorColor:[UIColor colorWithPatternImage:[UIImage imageNamed:...]]];
于 2013-05-28T12:17:18.737 に答える