Is there any functionality available to do an action sheet in iOS like the image below?
In the examples Declares folder, there is an example project called AlertSheet. Does this do the trick? I attempted to run the project to see if it’s what I’m looking for, but the app crashes in Simulator for me. I also tried copying over the AlertSheet folder from the example to my project, but that made mine crash too.
I also found iOSAlerts in the Declares folder and would use this if the alert sheet does not work, but would rather the sheet over the messagebox style in iOSAlerts example.
I have some private classes in iOSKit that do this. They don’t allow you to add textfields to an Alert right now, but they can definitely do what you picture there. I’ll add them and push an update in a few hours.
Thanks Jason. So the current iOSKit will have an alert sheet? I think I have your most current one. I don’t recall seeing it but will look again. Not needing to include textfields at this time in the sheet.
Side note… I love your work with iOSKit! It brings so many more options to Xojo iOS as still in the infancy stage!
It’s in my private test version right now which contains some unreleased classes. I’ll submit an update later today so they become available, but right now you won’t be able to see them.
I’m glad you enjoy iOSKit!
Great! Looking forward to it!
It will be a couple hours but I’ll post a message here when it’s done.
There is an iOSAlert module in the iOSAlerts project that ships with Xojo in the Example Projects\iOS\Declares folder that will do this for you too.
Thanks Jason. I looked into this as well before posting. I will use this one if needed, but it seems that iOSAlerts brings up the options in a messagebox style. If I am wrong, please correct me. I’d prefer the slick sheet come up from the bottom, but will use iOSAlerts if needed. Will be waiting to see what Jason K has new in iOSKit
If you call the actionBox method and pass a 0 as the final parameter (style) you’ll get the sheet coming up from the bottom. But be aware that this will crash an iPad as it needs a popover to be called in a different way. So on an iPad you need to always pass in a 1.
Interesting. Thank you for that Jason. I will give that a try today or tomorrow
since you are making this code in iOSKit… why not just have it over-ride the zero if it detects an iPad, and remove the concern from the developer
Ah…that’s because I didn’t write the code. It’s shipped with Xojo. You only need to read just a little bit further up the thread to see that Dave and save you and I both making additional, redundant posts.
iOSKit has been updated. The necessary classes are in UIKit.
Jason King … Jason Tait … I’m lucky I can remember the Jason part
I’m not sure this is true. It works just fine for me without crashing on the iPad simulator, and there is no mention of that in the Apple docs. I wonder if maybe there is a problem with the supplied example if you are seeing a crash?
It doesn’t crash in the iOS Simulator but it does crash on an iPad device. It was Dave who pointed this out to me about two months ago: https://forum.xojo.com/23392-iosalert-code-crashes-app-on-ipad.
Oh ok. Interesting that it works in the simulator then.
Yes, “interesting” and “frustrating” at the same time.
Jason, thank you for pushing this update through for iOSKit! I apologize for this question, but what items in the kit are needed for the alert sheet? There’s so many! I tried moving over just about everything in the modules folder and some other folders to my project but was getting several errors when trying to run (I think I am using some of your previous classes but not sure which ones and it’s finding duplicate ones). I deleted some of the items I thought were not relevant but still not compiling. I’m guessing there are some declares that are shared.
Not a problem, ask away! I think you will only need the UIKit and Foundation modules, although I haven’t tested to make sure (not at my computer right now). When copying stuff out of iOSKit you just need to copy the Modules folder into your project, everything else is just examples of the classes use and unit tests. Theoretically the only modules that have to be included for any of the other modules are the UIKit and Foundation modules, those are the shared modules referenced by all the others.