Skip to content

Instantly share code, notes, and snippets.

@nicwise
Created July 1, 2012 16:57
Show Gist options
  • Save nicwise/3028960 to your computer and use it in GitHub Desktop.
Save nicwise/3028960 to your computer and use it in GitHub Desktop.
List<string> buttons = new List<string>();
if (UIImagePickerController.IsCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Rear))
{
hasPhoto = true;
buttons.Add("Take a photo");
}
hasExisting = true;
buttons.Add("Choose Existing");
if (SourceImage != null)
{
hasCurrent = true;
buttons.Add("View current image");
}
buttons.Add("Cancel");
sheet = new UIActionSheet("", null, null, null, buttons.ToArray());
sheet.Clicked += delegate(object sender, UIButtonEventArgs e) {
if (e.ButtonIndex == sheet.CancelButtonIndex)
{
if (ImageSelected != null) ImageSelected();
return;
}
//lots of working code, based on e.ButtonIndex
};
sheet.CancelButtonIndex = buttons.Count-1;
sheet.ShowInView(ParentView.View);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment