How to Add a List (Picker or TableView) to the UIAlertController

Asked 2 years ago, Updated 2 years ago, 74 views

Hello
I am developing an iOS app with Objective-c.

I would like to display a pop-up dialog and add text input and UI to select items from the list.

I was able to use the UIAlertController and use "addTextFieldWithConfigurationHandler" to enter text, but I don't know how to add a list.

I don't care if it's a picker or a TableView list...

Can someone give me some useful information or tips?

ios objective-c xcode

2022-09-30 20:19

1 Answers

I don't know if... but in this case, you create your own subclass of the UIViewController.
As you may know, the UIAlertController is also based on the UIViewController.

The point is

  • Make the view background color clear and look like a pop-up dialog
  • From iOS 8 onwards, make the modalPresentationStyle UIModalPresentationOverCurrentContext so that the view controller on the back can be seen
  • Set an object that uses the UIViewControllerTransitioningDelegate protocol to the transitionDelegate and cause a pop-up-like transition
    • Returns objects that use the UIViewControllerAnimatedTransitioning protocol in the delivery method
  • Watch out for initiatives regarding screen rotation (it takes precedence if you bite the navigation controller, and if the modal display is this view controller alone, it will follow the settings on the back, and so on the back.US>After it became view controller base, it started to rotate during alert display, but it did not rotate before iOS 6).
  • Returns objects that use the UIViewControllerAnimatedTransitioning protocol in the delivery method

Yes.
View Controller view The following design can be done as usual on the storyboard.All you have to do is present... the view controller you created like this as usual.

Most tasks are probably the same as creating a view controller.Only UIViewControllerTransitioningDelegate and UIViewControllerAnimatedTransitioning will require learning.


2022-09-30 20:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.