여러 개의 UIImageview를 추가하는 스크롤보기가 있습니다.UILabel 인 하위 뷰를 제거하는 방법
각 이미지보기에 대해 UIButton 및 UILabel을 추가하고 있습니다.
이제 UILabel보기를 제거하고 싶습니다.
난 그냥 이미지 뷰와 버튼을 추가하고 여기에- (void)viewDidLoad {
[super viewDidLoad];
int h;
for (h=0; h<3; h++) {
UIImageView *k=[[UIImageView alloc]initWithFrame:CGRectMake(h*40, 0, 60, 90)];
k.backgroundColor=[UIColor yellowColor];
k.tag=h;
UIButton *j=[[UIButton alloc]initWithFrame:CGRectMake(20, 20, 20, 20)];
[j addTarget:self action:@selector(ge:) forControlEvents: UIControlEventTouchUpInside];
j.backgroundColor=[UIColor redColor];
[k addSubview:j];
k.userInteractionEnabled=YES;
[self.view addSubview:k];
}
}
아래에 내 코드를 찾아주세요. 레이블 UILabel의 제거 있으면 다른 버튼
-(IBAction)ge:(id)sender{
UIImageView *imageView = (UIImageView *)[sender superview];
for (UIView *jkl in [[sender superview]subviews]) {
if ([jkl isKindOfClass:[UILabel class]]){
[jkl removeFromSuperview];
} else {
UILabel *y=[[UILabel alloc]initWithFrame:CGRectMake(20, 20, 20, 20)];
y.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Close.jpeg"]];
[imageView addSubview:y];
}
}
}
에 사용자가 클릭하면
UILabel의
을 추가하지만, UILabel의 제거지고 있지 않습니다. 도와 주실 수 있니?