2013-11-04 4 views
1

나는 ICommand에 UILongPressGestureRecognizer 또는 MvvmCross에 MvxCommand와 같은 ios 제스처를 바인딩 할 수있는 방법을 찾고 있습니다.MvvmCross 바인딩 iOS 제스처

추 신 : 예 : here 예를 발견했지만 그 방법을 알아낼 수 없습니다. 당신이 발견 된 예에서 현재 MVVM 크로스 소스에서

+0

어떤 예제의 비트 수 너 알아 낸거야? 'Tap'을'LongPress'로 바꾸면,/작동하지 않습니다 - 컴파일 에러가 있습니까? 또는 런타임 예외? – Stuart

+0

LongPressBehaviour 및 BehaviourExtensions 클래스를 추가했지만 label.LongPress()를 만들 때; 그것을 인식하지 못합니다. –

답변

0

내가했던

public static class MvxBehaviourExtensions 
{ 
    public static MvxLongPressGestureRecognizerBehaviour LongPress(this UIView view) 
    { 
     var toReturn = new MvxLongPressGestureRecognizerBehaviour(view); 
     return toReturn; 
    } 
} 

public class MvxLongPressGestureRecognizerBehaviour 
    : MvxGestureRecognizerBehavior<UILongPressGestureRecognizer> 
{ 
    protected override void HandleGesture(UILongPressGestureRecognizer gesture) 
    { 
     // Long press recognizer fires continuously. This will ensure we fire 
     // the command only once. Fire as soon as gesture is recognized as 
     // a long press. 
     if (gesture.State == UIGestureRecognizerState.Began) 
     { 
      FireCommand(); 
     } 
    } 

    public MvxLongPressGestureRecognizerBehaviour(UIView target) 
    { 
     var lp = new UILongPressGestureRecognizer(HandleGesture); 

     AddGestureRecognizer(target, lp); 
    } 
} 

와 바인딩을 다음

set.Bind(this.LongPress()).For(lp => lp.Command).To(c => c.DoTheStuffCommand);