Search code examples
xamarin.iosuiactionsheetuitableview

MonoTouch - how can I pass a value back to my controller from a custom UIActionSheet?


I have a UIViewController with a UITableView. I have implemented a UITableViewDelegate and overridden the RowSelected event to display a custom ActionSheet with UIPickerView i.e. if the user selects a row the ActionSheet displays a list of choices for that row.

What I'm looking to do is ... when the user dismisses the custom ActionSheet (by pressing a Done button), the ActionSheet is dismissed, and the value of the selected item is passed back to the UIViewController for display purposes.

I'm a little unsure as to the best way to handle this. I was hoping someone might have some pointers ?


Solution

  • I think you should subclass UIActionSheet and subscribe to Dismissed and set a property for the value the user selected. (You can also do other work like fill up the action sheet from within the subclass)

    Your controller can then subscribe to Dismissed and read your new property.