muhaym / CrossPlacePicker

Cross Place Picker for Xamarin iOS, Android and Forms applications
MIT License
22 stars 12 forks source link

Place Picker in iPad Crashes #9

Open muhaym opened 6 years ago

muhaym commented 6 years ago

wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr

- line 1 NSGenericException: UIPopoverPresentationController () should have a non-nil sourceView or barButtonItem set before the presentation occurs.
ali-h2010 commented 6 years ago

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.

muhaym commented 6 years ago

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

ali-h2010 commented 6 years ago

@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.

muhaym commented 6 years ago

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

ali-h2010 commented 6 years ago

@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.

muhaym commented 6 years ago

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

ali-h2010 commented 6 years ago

@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 commented 6 years ago

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.

dblookup commented 6 years ago

+1