2015-01-02 4 views
1

레이블이있는 스크롤보기가 있으며, 누군가가 스크롤하여 X를 오른쪽으로 스크롤하고 손가락을 떼어서 삭제할 수 있습니다. 애니메이션 레이블. 스크롤보기 속성을 통해 스크롤보기에서 몇 개의 픽셀을 스크롤했는지 알 수 있습니다.

그래서 나는 대리자 연결을 생성하고, 스크롤 뷰의 대리자 메서드 추가 :

if myScrollView.someProperty moved X px's to the right and the user pulled his finger 

delete this label sliding with animation to the right 

누군가가 여기에 도와주세요 수 : 뭔가처럼 말하고 싶은이 방법

- (void)scrollViewDidScroll:(UIScrollView *)scrollView { 

    NSLog(@"scroll view did scroll"); 
} 

를/

tnx 앞서!

+0

어쩌면 scrool.contentOffset – AntonijoDev

답변

1

확인있는 UIScrollView의 contentOffset 속성 :

contentOffset - The point at which the origin of the content view is offset 
from the origin of the scroll view. 
0

이 작업을 수행하고 오른쪽에있는 라벨을 드래그 할 얼마나 많은 픽셀 정의 UISwipeGestureRecognizer를 사용할 수 있습니다. 다음 코드를 사용해보십시오

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    mylabel.userInteractionEnabled=YES; 
    [mylabel sizeToFit]; 
    [mylabel addGestureRecognizer:[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeLabel:)]]; 

} 

- (void)didSwipeLabel:(UISwipeGestureRecognizer*)swipe 
{ 
    NSLog(@"swipe"); 

    swipe.direction = UISwipeGestureRecognizerDirectionRight; 
    if (swipe.direction == UISwipeGestureRecognizerDirectionRight) { 
     [UIView animateWithDuration:0.5 animations:^{ 
      // swipe the label 50px right 
      mylabel.transform = CGAffineTransformMakeTranslation(50.0, 0.0); 
     } completion:^(BOOL finished) { 
      // when animation 
      [UIView animateWithDuration:0.5 animations:^{ 
       NSLog(@"label should be removed"); 
       [mylabel removeFromSuperview]; 
      }]; 
     }]; 




    } 
}