1
이 코드는 이전 iOS 버전에서 잘 작동했지만 현재 iOS 4.3에서는 더 이상 작동하지 않습니다. 누구든지 시정해야 할 사항에 대한 제안 사항이 있습니까?UIS 4.3에서 UISwipeGestureRecognizer가 작동하지 않습니다.
FinishedLaunching 이벤트에서 AddSyncGesture를 호출 한 다음 장치가 회전 할 때마다 메서드를 호출하는 방향 알림과 방향 변경으로 인한 수직 변경이 있으므로 제거하고 다시 추가해야합니다.
UISwipeGestureRecognizer sgr = null;
public void AddSyncGesture()
{
try {
if (sgr != null)
window.RemoveGestureRecognizer(sgr);
else
sgr = new UISwipeGestureRecognizer();
} catch (Exception ex) {
Logger.LogException(ex.Message, ex, "AddSyncGesture");
}
try {
sgr.NumberOfTouchesRequired = 2;
if (UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.LandscapeRight || UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.LandscapeLeft)
sgr.Direction = UISwipeGestureRecognizerDirection.Left | UISwipeGestureRecognizerDirection.Right;
else
sgr.Direction = UISwipeGestureRecognizerDirection.Up | UISwipeGestureRecognizerDirection.Down;
sgr.Delegate = new SwipeRecognizerDelegate();
sgr.AddTarget(this, SwipeSelector);
window.AddGestureRecognizer(sgr);
} catch (Exception ex) {
Logger.LogException(ex.Message, ex, "AddSyncGesture");
}
}
Selector SwipeSelector
{
get { return new Selector("HandleSwipe"); }
}
[Export("HandleSwipe")]
public void HandleSwipe(UISwipeGestureRecognizer recognizer)
{
if (Utils.CanSync)
Application.Synchronizer.Synchronize(true,Application.ProgressView);
}
class SwipeRecognizerDelegate : MonoTouch.UIKit.UIGestureRecognizerDelegate
{
public override bool ShouldReceiveTouch (UIGestureRecognizer recognizer, UITouch touch)
{
return true;
}
}
필요한 터치 횟수를 2로 설정하면 계속 작동합니까? – Neal
예, 문제없이 계속 작동합니다. 나는 실제 장치에서 4.3 버전으로 시험해 보았다. – Scarlaxx
고마워, 내가 계속 살펴볼거야. 실제로 FinishedLaunching 이벤트의 창에 내 GR을 추가하여 앱을 사용할 수 있도록합니다. 4.3 이전에 일했습니다. – Neal