2014-07-10 5 views
1
  • 을 제거하여 서브 뷰 크기 조정 나는 3 subivewsview A, view B, view C라고 들어 볼 수 있습니다.
  • 하위 뷰를 제거하면 자동으로 여백을 설정해야합니다.
  • view A을 제거하면 나머지 views이 자동으로 올라와야합니다.

참고 : 안에는 autolayout이 없습니다. 뷰를 숨기기 위해 가지고있는 당신이보기의 -contentoffset 속성을 설정해야합니다 밀어 원하는보기 속성 관리자에서이 들어 automask아이폰 OS가 : 하위 뷰

enter image description here

답변

1

, 당신은 비트를 프로그램 할 필요가, 당신은 내가 도움이되기를 바랍니다,

//Adding Delete Tap Gesture 
-(void)addGestureToSubViews{ 
    for(UIView *view in parent.subviews){ 
     UITapGestureRecognizer *gesture=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(deleteAction:)]; 
     [view addGestureRecognizer:gesture]; 
    } 
} 


-(IBAction)deleteAction:(UITapGestureRecognizer *)sender{ 
    UIView *view=sender.view; 

    [UIView animateWithDuration:.3 animations:^{ 
     CGRect rect=view.frame; 
     rect.origin.x=view.superview.frame.size.width; 
     view.frame=rect; 
    } completion:^(BOOL finished) { 
     [self reArrangeSuperView:view.superview withDeletedViewFrame:view.frame]; 
     [view removeFromSuperview]; 

    }]; 

} 

-(void)reArrangeSuperView:(UIView *)superView withDeletedViewFrame:(CGRect)frame{ 

    for(UIView *view in superView.subviews){ 
     CGRect rect=view.frame; 

     if(rect.origin.y>frame.origin.y){ 
      rect.origin.y=frame.origin.y; 
     } 

     [UIView animateWithDuration:.3 animations:^{ 
      view.frame=rect; 
     }]; 

    } 
} 

이것을 달성하기 위해 다음 코드를 시도 할 수 있습니다.

건배.

+0

정말 도움이되는 사람 ... 고마워요. – svmrajesh

+0

보기 A를 제거하면보기 B도 제거됩니다.보기 B 높이가 너무 깁니다. – svmrajesh

+0

이 수정을 위해 if (rect.origin .y> frame.origin.y)'. 당신의 필요에 따라. .. – iphonic

0

얼마나 그것의 가능한 알려주세요. 그것은 자동으로 작동하지 않습니다