我目前正在制作一个照片装饰应用程序。*holderView 是用户选择的贴纸。每当我尝试从照片库加载照片或拍摄照片然后加载回此页面时,额外的 *holderView 以编程方式添加,这是我之前在拍照之前选择的贴纸,之后会出现重复的贴纸,这不是我想要的。
我应该如何编写代码以防止这种情况发生?非常感谢。
- (void)viewWillAppear:(BOOL)animated {
UIView *holderView = [[UIView alloc] initWithFrame:CGRectMake(0, 50, _imagePicker.selectedImage.size.width, _imagePicker.selectedImage.size.height)];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:[holderView frame]];
[imageView setImage:_imagePicker.selectedImage];
[holderView addSubview:imageView];
...
}