2010-04-26 4 views
0

사실 저는 스크롤 뷰가 있습니다. 30 버튼을 사용하고 있습니다. 내 요구 사항은 버튼을 재정렬해야한다는 것입니다. 마찬가지로, 어떤 버튼을 만졌을 때 그것은 우리의 터치로 선택되어야합니다. 우리가 스크롤 - 뷰에서 움직이는 곳은 우리의 터치와 함께 움직여야합니다. 내가 터치를 마친 후에는 버튼을 교체해야합니다. 어느 누구도 이것에 관해 나를 도와 줄 수 있습니까? .........우리는 touchesBegan, touchesMoved, scrollview에 대해 touchesEnded를 사용할 수 없습니까?

+0

어떤 요구 사항에 문제가 있습니까? – Vladimir

답변

0

당신은이 일을 할 수 있지만 많은 일들이 있습니다. 다음이 필요합니다.
1. 단추가 될 UIControl 서브 클래스를 작성하십시오.
2. 모든 터치 * 메소드를 무시합니다.
3. 표준 uicontrol 동작 + 동작 동작을 구현하십시오.

#pragma mark - 
#pragma mark Touches delegate methods 

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 

    UITouch *touch = [touches anyObject]; 
    [self performSelector:@selector(delayedTouchBeging:) withObject:touch afterDelay:0.15]; 

    [super touchesBegan:touches withEvent:event]; 

} 


- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 
    UITouch *touch = [touches anyObject]; 
    if (dragging) { 
     // move your view in new position here  
    } else { 
     [super touchesMoved:touches withEvent:event];  
    } 

} 

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 

    if (dragging) { 

     // Do other stuff if you need 

    } else { 
     [super touchesEnded:touches withEvent:event]; 
    } 

    dragging = NO; 
    [NSObject cancelPreviousPerformRequestsWithTarget:self]; 

} 


- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { 
    [self touchesEnded:touches withEvent:event]; 
} 

- (void) delayedTouchBeging:(UITouch*) touch { 
    dragging = YES; 

    [self cancelTrackingWithEvent:nil]; 

    // Do here stuff about begin moving (animation, etc) 

} 
0

"Launcher"코드는 무료로 제공되는 three20 코드 카탈로그의 일부로 사용하는 방법을 살펴볼 수 있습니다. 그들은 정확히 이와 같은 작업을 수행합니다 (iPhone 앱보기에서 주변을 이동하거나 삭제할 수있는 곳을 모방합니다).

http://github.com/facebook/three20

관련 문제