Open ntbao17 opened 3 months ago
@ntbao17 Which version did you tested? I have tested the latest version 1.0.8 with the RGPopup.Samples on my own device. It seems work for me. Can you provide more detail about this issue, same code snips or a demo project? Thanks.
I use version 1.0.8, I send you a demo in which there is an error when using vs popup => MauiContext should have been set on parent to use. As for using vs page, I usually only try it on iOS. Please help me see, thank you very much!
After testing the demo project you uploaded, there are two incorrect points in your code.
//Case 1
var pagecrop = new Pages.PageCropImage(sourceStream);
pagecrop.OnCropImageComplete += (r) =>
{
Navigation.PopAsync();
};
await Navigation.PushAsync(pagecrop);
Navigation.PushAsync and Navigation.PopAsync are MAUI framework's methods. They pop new page to the system navigation stack, but not to current page window. The right methods should be Navigation.PushPopupAsync and Navigation.PopPopupAsync (Or you can use PopupNavigation.Instance to replace Navigation to call PushAsync and PopAsync). And PageCropImage should extends from PopupPage but not from ContentPage. Like:
public partial class PageCropImage : PopupPage
var pagecrop = new Pages.PageCropImage(sourceStream); pagecrop.OnCropImageComplete += async (r) => { await Navigation.PopPopupAsync(); }; await Navigation.PushPopupAsync(pagecrop);
2. For test case 2, the Syncfusion.Maui.ImageEditor seems not support to work in a dynamic set content view. **PopupHelper.ShowPopup** will generate a BasePopupPage and replace its content by the content view you gaven dynamically. From the debug error, it crashed when calling **Syncfusion.Maui.ImageEditor.ImageEditLayout.SaveCrop()** method from **var stream = await ImageEditor.GetImageStream();**. Here is the full stacktrace:
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view)
at Microsoft.Maui.Handlers.LayoutHandler.Remove(IView child)
at Microsoft.Maui.Handlers.LayoutHandler.MapRemove(ILayoutHandler handler, ILayout layout, Object arg)
at Microsoft.Maui.CommandMapper`2.<>c__DisplayClass6_0[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.ILayoutHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
I think it may be a unsupport issue in **Syncfusion.Maui.ImageEditor** but not in RGPopup.Maui.
**After correcting the case 1 code, it works fine for me.**
In case 1, I use pagecontent to demonstrate that ImageEditor.GetImageStream() works well. In case 2, when using popup from RGPopup.Maui, the error is as you sent above. Please help me see, thank you very much!
PopupHelper.ShowPopup is not the recommend way to pop PopupPage content. As I said, it may not be supportted by MAUI framework or Syncfusion.Maui.ImageEditor. The reccomend way is to make PageCropImage inherit from PopupPage. And then just popup the PageCropImage.
public partial class PageCropImage : PopupPage
.....
//Case 1
var pagecrop = new Pages.PageCropImage(sourceStream);
pagecrop.OnCropImageComplete += async (r) =>
{
await Navigation.PopPopupAsync();
};
await Navigation.PushPopupAsync(pagecrop);
Terminating app due to uncaught exception 'System.ObjectDisposedException', reason: 'Cannot access a disposed object. Object name: 'RGPopup.Maui.IOS.Platform.PopupWindow'. (System.ObjectDisposedException) at ObjCRuntime.ThrowHelper.ThrowObjectDisposedException(Object o) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/ThrowHelper.cs:line 52 at Foundation.NSObject.get_SuperHandle() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSObject2.cs:line 615 at UIKit.UIWindow.get_RootViewController() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/UIKit/UIWindow.g.cs:line 385 at BigTed.ProgressHUD.RemoveHud() at Foundation.NSActionDispatcher.Apply() in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:line 61 at Foundation.NSObject.InvokeOnMainThread(Action action) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSObject2.cs:line 782 at BigTed.ProgressHUD.b145_1()
at UIKit.UIView.<>c__DisplayClass12_0.b 0(Boolean x) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIView.cs:line 124
at ObjCRuntime.Trampolines.SDUICompletionHandler.Invoke(IntPtr block, Byte finished) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/ObjCRuntime/Trampolines.g.cs:line 45753
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
at ClubSync.Program.Main(String[] args) in /Users/admin/Projects/GitTea/ClubSyncMobile/Clubsync/Platforms/iOS/Program.cs:line 13
'
First throw call stack: