CrossPlacePicker icon indicating copy to clipboard operation
CrossPlacePicker copied to clipboard

Place Picker in iPad Crashes

Open muhaym opened this issue 6 years ago • 9 comments

wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr - line 1 NSGenericException: UIPopoverPresentationController (<UIPopoverPresentationController: 0x12b61d850>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.

muhaym avatar Apr 16 '18 14:04 muhaym

I am facing the same issue Unhandled managed exception: Objective-C exception thrown. Name: NSGenericException Reason: UIPopoverPresentationController (<UIPopoverPresentationController: 0x11bbc9ea0>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.

ali-h2010 avatar May 04 '18 21:05 ali-h2010

Since I am busy, till I work on next update, any one can take and fix the logic to support Ipads

muhaym avatar May 05 '18 05:05 muhaym

@muhaym Thanks for the update. It's better than ignoring the issues as some developers do. There are so much potential and features that you can also add such as changing map type ,pick multiple places ,...

I don't have a lot of experience in swift or Objective C but if the code is clean and well documented, I might be able to somehow add those options if not already there.

ali-h2010 avatar May 05 '18 10:05 ali-h2010

This is pure C#, have a look at https://github.com/muhaym/CrossPlacePicker/blob/master/src/CrossPlacePicker/Plugin.CrossPlacePicker.iOS/CrossPlacePickerImplementation.cs

This might be a simple fix.

Regarding other features, if it's available in Google Place Picker for iOS and Android, I am happy to implement it, but I don't think Google Place Picker supports it. This is just wrapper over native Place Pickers provided by google, and I just made it dead simple to use it

muhaym avatar May 05 '18 10:05 muhaym

@muhaym is there a way for now just to handle the crashing? The code is surrounded with try and catch but the error occurs in the native code.

ali-h2010 avatar May 05 '18 10:05 ali-h2010

https://github.com/muhaym/CrossPlacePicker/blob/7f9666b95775bcd32ad41d26145b9e149fdea368/src/CrossPlacePicker/Plugin.CrossPlacePicker.iOS/CrossPlacePickerImplementation.cs#L82

This is the place you have to add the fix, making it support Tablet.

A reference is here, but need to make sure it's backwards compatible and don't break anything.

https://stackoverflow.com/questions/42920340/uipopoverpresentationcontroller-should-have-a-non-nil-sourceview-or-barbuttonite

muhaym avatar May 05 '18 10:05 muhaym

@muhaym , what kind of technique did you use to covert the code from Swift or Objective C to C#? Can you please just refer me to a resource or method name so I can learn it myself?

ali-h2010 avatar May 14 '18 12:05 ali-h2010

if anyone is facing this issue , you can handle the tablet size and show a message instead of the crash. if (Device.Idiom == TargetIdiom.Tablet) { await _pageDialogService.DisplayAlertAsync("Alert", "Taking picture is not supported in tablets, please use the remarks to describe the location.", "OK"); return; }

I learned a little about how to create plugins. Xamarin has access to native SDK and you can add specific code in each platform. You can also call other libraries and use them. It's like creating a custom renderer or dependency service.

I might work on a fix later but I am sure that the developer that I am very thankful for is the most expert to solve it in his coming update.

ali-h2010 avatar May 16 '18 17:05 ali-h2010

+1

dblookup avatar Jun 12 '18 10:06 dblookup