0

I was trying to create a UIActionSheet in a Xamarin.ios app, where there is an image and text in each row. Is there a way we could do that?

I've followed the sample provided by Alanc Liu in this link: For "actionSheetAlert", what's after (action) =>.

This is just text, however. How can I replace the string with a combination of image + string?

Screenshot attached to clarify the requirement... Need to add custom images in place of all those smiley faces.

Thank you.

enter image description here

Stout
  • 463
  • 8
  • 19
  • Thank you for the suggestion. I appreciate the time and code sample, but unfortunately these Swift APIs do not have a one-to-one alternative in C#, xamarin.ios. If there is a way to get it done in C# it would be great. – Stout Aug 22 '19 at 17:06

4 Answers4

1

This isn't possible with a stock UIAlertController/UIAlertAction. You would need to create a custom view controller to get this functionality.

AdamPro13
  • 7,232
  • 2
  • 30
  • 28
1

UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with present(_:animated:completion:).

Important: UIActionSheet is deprecated in iOS 8. (Note that UIActionSheetDelegate is also deprecated.) Source

Blazej SLEBODA
  • 8,936
  • 7
  • 53
  • 93
0

I have used Alert and Picker from dillidon for the basic implementations, the library packs a lot of options for you to choose. For more customisations that can't be supported by the library I tend to create my own controller.

Joshua
  • 2,432
  • 1
  • 20
  • 29
0

It is possible(without using external library) by overriding one of the properties of alert action. I have achieved the same by following code:

      let actionsheet = UIAlertController.init(title: "Select party", message: nil, preferredStyle: .actionSheet)
        let actn1 = UIAlertAction.init(title: "Party 1", style: .default, handler: { (act) in
            //
        })
        actn1.setValue(UIImage(named: "String"), forKey: "image")
        actionsheet.addAction(actn1)
      self.present(actionsheet, animated: true, completion: nil)

And here you go. Hope this help you.

khush
  • 540
  • 5
  • 16
  • Thank you for the suggestion. Unfortunately these APIs do not have a one-to-one alternative in C#, xamarin.ios. If there is a way to get it done in C# it would be great. Thank you. – Stout Aug 22 '19 at 17:05