iOSAlert Code Crashes App on iPad

I have an app that makes use of the iOSAlert module and methods supplied with Xojo in the iOS\Declares folder. While this all works well on iPhones and on the iOS Simulator, it crashes my app on iPads.

When I use


on an actual iPad, my app crashes and the following appears in the crash log:

Again, just to reiterate, this crash:

  • Does not occur on iPhones; and
  • Does not occur on an iPad when the app is run in the iOS Simulator
  • Only occurs on an actual iPad

Has anybody else run into this issue?

So I’ve found a workaround. The last property of the actionBox method is style as integer. In my app I usually pass 0 here as I like the messages to popup from the bottom of the screen. However setting style to 0 causes this crash on an iPad. So I’ve added a single-line over-rider that changes style to 1 (alert box in the middle of the screen) if the device is an iPad and that has fixed the problem.

This is due to the fact that iOS handles this control totally differently between iPhone and iPad

for iPad … you must supply the location information for the alert. (which is mentioned in the error message)

Search Google, and you will see many instances of this same issue mentioned for both ObjC and Swift

popoverController.sourceRect = sender.bounds

Ah right, thanks Dave. I think I’ll stick with my workaround for now.