You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using SlideOverKit for my Xamarin App and it's working well until I encountered a problem on iOS devices.
I got a PageImpInterfaceRendereriOS.cs like this one :
using System;
using Xamarin.Forms;
//using SlideOverKit.MoreSample;
//using SlideOverKit.MoreSample.iOS;
using Xamarin.Forms.Platform.iOS;
using SlideOverKit.iOS;
using UIKit;
using CoreGraphics;
using Livli;
using Livli.iOS.Renderers;
[assembly: ExportRenderer(typeof(TimelinePage), typeof(PageImpInterfaceRendereiOS))]
namespace Livli.iOS.Renderers
{
// As your page cannot inherit from MenuContainerPage,
// You must create a renderer page, copy these codes and rename.
public class PageImpInterfaceRendereiOS : PageRenderer, ISlideOverKitPageRendereriOS
{
public Action<bool> ViewDidAppearEvent { get; set; }
public Action<VisualElementChangedEventArgs> OnElementChangedEvent { get; set; }
public Action ViewDidLayoutSubviewsEvent { get; set; }
public Action<bool> ViewDidDisappearEvent { get; set; }
public Action<CGSize, IUIViewControllerTransitionCoordinator> ViewWillTransitionToSizeEvent { get; set; }
public PageImpInterfaceRendereiOS()
{
new SlideOverKitiOSHandler().Init(this);
}
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
Console.WriteLine("SLIDEOVERKIT OnElementChanged");
Console.WriteLine("NewElement.WidthRequest:" + e.NewElement.WidthRequest);
if (e.NewElement.WidthRequest < 0) return;
base.OnElementChanged(e);
if (OnElementChangedEvent != null)
OnElementChangedEvent(e);
}
public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews();
if (ViewDidLayoutSubviewsEvent != null)
ViewDidLayoutSubviewsEvent();
}
public override void ViewDidAppear(bool animated)
{
Console.WriteLine("SLIDEOVERKIT ViewDidAppear");
base.ViewDidAppear(animated);
if (ViewDidAppearEvent != null)
ViewDidAppearEvent(animated);
}
public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
if (ViewDidDisappearEvent != null)
ViewDidDisappearEvent(animated);
}
public override void ViewWillTransitionToSize(CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
{
Console.WriteLine("SLIDEOVERKIT ViewWillTransitionToSize");
base.ViewWillTransitionToSize(toSize, coordinator);
if (ViewWillTransitionToSizeEvent != null)
ViewWillTransitionToSizeEvent(toSize, coordinator);
}
}
}
It's working well if the user start the App himself. But I got push notifications on my App and when the App is killed and the user tap on the notification message to open it, the App is crashing. So in my device logs I have :
[AppCenterCrashes] ERROR: +[MSWrapperLogger MSWrapperLog:tag:level:]/10 Unhandled Exception:
System.Exception: Please set SildeMenuView WidthRequest
at SlideOverKit.HorizontalGestures.CheckViewBound (SlideOverKit.SlideMenuView view) [0x0003c] in C:\Users\Jesse\Documents\Visual Studio 2017\Projects\SlideOverKit\SlideOverKit\Gestures\HorizontalGestures.cs:22
at SlideOverKit.HorizontalGestures..ctor (SlideOverKit.SlideMenuView view, System.Double density) [0x0000f] in C:\Users\Jesse\Documents\Visual Studio 2017\Projects\SlideOverKit\SlideOverKit\Gestures\HorizontalGestures.cs:12
at SlideOverKit.DragGestureFactory.GetGestureByView (SlideOverKit.SlideMenuView view, System.Double density) [0x00037] in C:\Users\Jesse\Documents\Visual Studio 2017\Projects\SlideOverKit\SlideOverKit\Gestures\DragGestureFactory.cs:17
at SlideOverKit.iOS.SlideOverKitiOSHandler.LayoutMenu () [0x00030] in <67cebbfd044c477f80909f816f090e8c>:0
at SlideOverKit.iOS.SlideOverKitiOSHandler.OnElementChange<…>
That's why I wrote the following line : if (e.NewElement.WidthRequest < 0) return;
So the App doesn't crash anymore but the SlideMenu still broke.
The text was updated successfully, but these errors were encountered:
Ok I just figured out after 2 days of research a little "hack" to solve my problem.
In fact, inside the OnElementChanged method, e.NewElement.SlideMenu.WidthRequest and e.NewElement.SlideMenu.WidthRequest are taking the App.Current.MainPage.Width and App.Current.MainPage.Height.
But when you click on the iOS notification, thoses values are equals to 0.
I solved this problem by adding these two conditions :
if (((MyPage)e.NewElement).SlideMenu.HeightRequest <= 0) ((MyPage)e.NewElement).SlideMenu.HeightRequest = 2000;
if (((MyPage)e.NewElement).SlideMenu.WidthRequest <= 0) ((MyPage)e.NewElement).SlideMenu.WidthRequest = 320;
For the HeightRequest I took 2000 because if the SlideMenu exceed the user won't see it.
For the WidthRequest I took 320, it's the value of App.Current.MainPage.WidthRequest on iPhone 7.
It's a hack to patch my problem in production, I will continue a bit more to find a better solution.
Hello,
I'm using SlideOverKit for my Xamarin App and it's working well until I encountered a problem on iOS devices.
I got a PageImpInterfaceRendereriOS.cs like this one :
It's working well if the user start the App himself. But I got push notifications on my App and when the App is killed and the user tap on the notification message to open it, the App is crashing. So in my device logs I have :
That's why I wrote the following line :
if (e.NewElement.WidthRequest < 0) return;
So the App doesn't crash anymore but the SlideMenu still broke.
The text was updated successfully, but these errors were encountered: