2013-04-01 1 views
0

* cellSeparator 및 다른 UILabels로 명명 된 일부 동적 UIView를 추가하려고합니다 ... 이제는이 코드를 다시 호출하여 레이블 텍스트를 다시 작성하고 이전에 작성한 레이블 텍스트를 덮어 쓰면 어떻게됩니까? UIView의 동적으로 생성 beacause를이 IOS에 development.so 사람이 내가 다시 만들기 전에이 UIView의를 동적으로 제거 할 수있는 방법을 말해 주실 래요? 내가 UIView의동적으로 생성 된 UIView 및 UILabel 텍스트를 제거하는 방법?

UILabel *indexLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, self.view.frame.size.height-150, self.view.frame.size.width/2,30)]; 
      [indexLabel setBackgroundColor:[UIColor clearColor]]; 
      indexLabel.textColor = [UIColor whiteColor]; 
      indexLabel.text = @"Details:-"; 
      indexLabel.font = [UIFont systemFontOfSize:20.00]; 
      UILabel *tagLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, self.view.frame.size.height-120, self.view.frame.size.width/2, 30)]; 
      tagLabel.backgroundColor = [UIColor clearColor]; 


      NSLog(@"LOg %@",imageId); 
      NSLog(@"LOg %@",imageStyle); 
      NSLog(@"LOg %@",imageType); 
      NSLog(@"LOg %@",imageWeight); 
      tagLabel.text = [NSString stringWithFormat:@"The Id of Jewl Is: %@",imageId]; 

      imageTypelabel= [[UILabel alloc] initWithFrame:CGRectMake(20, self.view.frame.size.height-90, self.view.frame.size.width/2, 30)]; 
      imageTypelabel.backgroundColor = [UIColor clearColor]; 
      imageTypelabel.text = [NSString stringWithFormat:@"The Type of Jewl Is: %@",imageType]; 
      imageStylelabel = [[UILabel alloc] initWithFrame:CGRectMake(20, self.view.frame.size.height-60, self.view.frame.size.width/2, 30)]; 
      imageTypelabel.backgroundColor = [UIColor clearColor]; 
      imageStylelabel.text = [NSString stringWithFormat:@"The style of Jewl Is: %@",imageStyle]; 
      imageWeightlabel = [[UILabel alloc] initWithFrame:CGRectMake(20, self.view.frame.size.height-30, self.view.frame.size.width/2, 30)]; 
      imageStylelabel.backgroundColor = [UIColor clearColor]; 
      imageWeightlabel.text = [NSString stringWithFormat:@"The weight of Jewl Is: %@",imageWeight]; 
      imageWeightlabel.backgroundColor = [UIColor clearColor]; 
      imageWeightlabel.textColor = [UIColor whiteColor]; 
      imageTypelabel.textColor = [UIColor whiteColor]; 
      imageWeightlabel.textColor = [UIColor whiteColor]; 
      tagLabel.textColor = [UIColor whiteColor]; 
      UIImage *imageBegin = [UIImage imageNamed:imageName]; 
      UIImageView *imageView = [[UIImageView alloc] initWithImage:imageBegin]; 


      UIView *cellSeparator = [[UIView alloc] initWithFrame:CGRectMake(0,545, self.view.frame.size.width ,3)]; 
      cellSeparator.tag=1; 
      [cellSeparator setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin | 
      UIViewAutoresizingFlexibleRightMargin | 
      UIViewAutoresizingFlexibleWidth];  
      [cellSeparator setContentMode:UIViewContentModeTopLeft];  
      [cellSeparator setBackgroundColor:[UIColor whiteColor]]; 
      [self.view addSubview:cellSeparator]; 
+0

두 번째로 전화 할 때 수퍼 뷰의 하위보기를 제거 하시겠습니까? – Balu

+2

1. Xcode 질문이 아닙니다. 2. 클래스는 'UIVIEW'가 아니라 'UIView'라고합니다. –

+0

레이블을 추가하는 뷰와 이미지보기 –

답변

7

당신은 모두 제거하는 방법을 쓸 수 있음을 제거하는 방법을 잘 모릅니다 보기의 하위보기 및 필요에 따라이 코드를 수정하십시오.

- (void)removeSubviewsOfView 
{ 
    NSArray *subViews = [self.view subviews]; 
    for(UIView *view in subViews) 
    { 
     [view removeFromSuperview]; 
    } 
} 
+0

고맙습니다 ... 내 문제를 해결했습니다 \ –

관련 문제