diff --git a/Demo/App.Android/Resources/Resource.designer.cs b/Demo/App.Android/Resources/Resource.designer.cs index 3321fc3..3db0a20 100644 --- a/Demo/App.Android/Resources/Resource.designer.cs +++ b/Demo/App.Android/Resources/Resource.designer.cs @@ -14,7 +14,7 @@ namespace App.Droid { - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.2.0.155")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "13.2.0.99")] public partial class Resource { diff --git a/Scr/StateButton.Android/Resources/Resource.designer.cs b/Scr/StateButton.Android/Resources/Resource.designer.cs index df9bff8..d491558 100644 --- a/Scr/StateButton.Android/Resources/Resource.designer.cs +++ b/Scr/StateButton.Android/Resources/Resource.designer.cs @@ -14,7 +14,7 @@ namespace StateButton.Android { - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.2.0.155")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "13.2.0.99")] public partial class Resource { diff --git a/Scr/StateButton.iOS/StateButtonRenderer.cs b/Scr/StateButton.iOS/StateButtonRenderer.cs index a34cd86..5cb890f 100644 --- a/Scr/StateButton.iOS/StateButtonRenderer.cs +++ b/Scr/StateButton.iOS/StateButtonRenderer.cs @@ -1,5 +1,6 @@ using Foundation; using StateButton.iOS; +using System; using System.Linq; using UIKit; using Xamarin.Forms; @@ -17,67 +18,95 @@ public class StateButtonRenderer : FrameRenderer protected override void OnElementChanged(ElementChangedEventArgs e) { - base.OnElementChanged(e); + try + { + base.OnElementChanged(e); - AccessibilityTraits = UIAccessibilityTrait.Button; + AccessibilityTraits = UIAccessibilityTrait.Button; - if (e.OldElement != null) return; + if (e.OldElement != null) return; - if (!e.NewElement.GestureRecognizers.Any()) - return; + if (!e.NewElement.GestureRecognizers.Any()) + return; - if (e.NewElement.GestureRecognizers.All(x => x.GetType() != typeof(TouchGestureRecognizer))) - return; + if (e.NewElement.GestureRecognizers.All(x => !(x is TouchGestureRecognizer))) + return; - AddGestureRecognizer(new UITapGestureRecognizer(() => - { - foreach (IGestureRecognizer recognizer in Element.GestureRecognizers.Where(x => x is TouchGestureRecognizer)) + AddGestureRecognizer(new UITapGestureRecognizer(() => { - if (recognizer is TouchGestureRecognizer touchGestureRecognizer) + foreach (IGestureRecognizer recognizer in Element.GestureRecognizers.Where(x => x is TouchGestureRecognizer)) { - touchGestureRecognizer.Clicked(); + if (recognizer is TouchGestureRecognizer touchGestureRecognizer) + { + touchGestureRecognizer.Clicked(); + } } - } - })); + })); + } + catch (Exception) + { + // ignored + } } public override void TouchesMoved(NSSet touches, UIEvent evt) { - base.TouchesMoved(touches, evt); - - foreach (IGestureRecognizer recognizer in Element.GestureRecognizers.Where(x => x is TouchGestureRecognizer)) + try { - if (recognizer is TouchGestureRecognizer touchGestureRecognizer) + base.TouchesMoved(touches, evt); + + foreach (IGestureRecognizer recognizer in Element.GestureRecognizers.Where(x => x is TouchGestureRecognizer)) { - touchGestureRecognizer.Released(); + if (recognizer is TouchGestureRecognizer touchGestureRecognizer) + { + touchGestureRecognizer.Released(); + } } } + catch (Exception) + { + // ignored + } } public override void TouchesBegan(NSSet touches, UIEvent evt) { - base.TouchesBegan(touches, evt); - - foreach (IGestureRecognizer recognizer in Element.GestureRecognizers.Where(x => x is TouchGestureRecognizer)) + try { - if (recognizer is TouchGestureRecognizer touchGestureRecognizer) + base.TouchesBegan(touches, evt); + + foreach (IGestureRecognizer recognizer in Element.GestureRecognizers.Where(x => x is TouchGestureRecognizer)) { - touchGestureRecognizer.Pressed(); + if (recognizer is TouchGestureRecognizer touchGestureRecognizer) + { + touchGestureRecognizer.Pressed(); + } } } + catch (Exception) + { + // ignored + } } public override void TouchesCancelled(NSSet touches, UIEvent evt) { - base.TouchesCancelled(touches, evt); - - foreach (IGestureRecognizer recognizer in Element.GestureRecognizers.Where(x => x is TouchGestureRecognizer)) + try { - if (recognizer is TouchGestureRecognizer touchGestureRecognizer) + base.TouchesCancelled(touches, evt); + + foreach (IGestureRecognizer recognizer in Element.GestureRecognizers.Where(x => x is TouchGestureRecognizer)) { - touchGestureRecognizer.Released(); + if (recognizer is TouchGestureRecognizer touchGestureRecognizer) + { + touchGestureRecognizer.Released(); + } } } + catch (Exception) + { + // ignored + } } } } \ No newline at end of file