0

How we can add a table view in the action sheet. am using xamarin ios. I need an action sheet with a table view which has an accordion. I can do normal table view with accordion. I need the table view inside the action sheet

shamnad
  • 328
  • 5
  • 21

1 Answers1

0

The first thing you should do is to use UIAlertController instead of the UIActionSheet, which was deprecated in iOS 8. You'll have a more future proof app with an easier to work with alert functionality.

UIAlertController inherits from UIViewController which let's you add subviews as you desire.

// Create a new UIAlertController
var alertController = UIAlertController.Create("Alert Title", "Some text here", UIAlertControllerStyle.ActionSheet);

// Add your custom view to the alert. Any UIView can be added.
var yourTableView = new UITableView();
alertController.View.AddSubview(yourTableView)

// Add Actions
alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, alert => Console.WriteLine ("Ok clicked")));
alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, alert => Console.WriteLine ("Cancel clicked")));

// Show the alert
controller.PresentViewController(alertController, true, null);

Here's an example of this in action, although it's in Swift.

Timo Salomäki
  • 7,099
  • 3
  • 25
  • 40