gpt4 book ai didi

ios - 自定义 UITableViewCell,重新排序时删除初始 View

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:43:22 25 4
gpt4 key购买 nike

我有一个看起来像这样的自定义单元格

细胞

-ContainingView(称为cellframe)

--标签

--标签

包含 View 的原因是我可以在单元格周围设置阴影。

下面是我的代码

#import "QuickNoteMasterViewCell.h"
#import <QuartzCore/QuartzCore.h>

@interface QuickNoteMasterViewCell ()

@property (nonatomic, strong) CAShapeLayer *shapeLayer;

@end



@implementation QuickNoteMasterViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];

// Configure the view for the selected state

}

-(void)setEditing:(BOOL)editing{

}

// this adds shadow and border to the cell

- (void)configureBackgroundView
{
UIView *cellFrame = self.cellFrame;
//cellFrame.layer.borderColor = [UIColor whiteColor].CGColor;
//cellFrame.layer.borderWidth = 10.;

CGSize size = cellFrame.bounds.size;
CGFloat curlFactor = 15.0f;
CGFloat shadowDepth = 5.0f;
cellFrame.layer.shadowColor = [UIColor blackColor].CGColor;
cellFrame.layer.shadowOpacity = 1.f;
cellFrame.layer.shadowOffset = CGSizeMake(.0f, 3.0f);
cellFrame.layer.shadowRadius = 3.0f;
cellFrame.layer.masksToBounds = NO;

UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0.0f, 0.0f)];
[path addLineToPoint:CGPointMake(size.width, 0.0f)];
[path addLineToPoint:CGPointMake(size.width, size.height + shadowDepth)];
[path addCurveToPoint:CGPointMake(0.0f, size.height + shadowDepth)
controlPoint1:CGPointMake(size.width - curlFactor, size.height + shadowDepth - curlFactor)
controlPoint2:CGPointMake(curlFactor, size.height + shadowDepth - curlFactor)];
cellFrame.layer.shadowPath = path.CGPath;
}


- (void)layoutSubviews
{
[super layoutSubviews];

[self configureBackgroundView];

}



@end

before drag

问题是,当我重新排列单元格时,ContainingView(称为单元格框架)被移除。

during drag

有什么解决办法吗?

最佳答案

当 UITableViewCell 被重新排序时,TableView 将隐藏所有不是 UILabel 或 UIImageView 的东西。

不太清楚它为什么这样做,但我不知道有什么办法可以解决这个问题。我知道唯一可行的方法是将阴影 View 创建为图像并将 UIView 切换为 UIImageView。

对不起!

关于ios - 自定义 UITableViewCell,重新排序时删除初始 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14400417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com