I wish to move the cancel button to the bottom of my actionsheet, to be the last button available to the user. I have this code:
func openImagePicker(
actionSheetTitle:String="Choose Image Source",
cancelTitle:String="Cancel",
cameraTitle:String="Camera",
galleryTitle:String="Gallery",
isImage:Bool=true,
isMultipleSelection:Bool=false,
completeHandler:(success:Bool,arrAssert:[TCAsset])->Void,
failurer:((error:String)->(Void))?=nil)
{
let actionSheet=UIActionSheet(title: actionSheetTitle, delegate:self, cancelButtonTitle:nil, destructiveButtonTitle:cancelTitle,otherButtonTitles: cameraTitle, galleryTitle)
if UIDevice.currentDevice().userInterfaceIdiom == .Phone
{
actionSheet.showInView(UIApplication.sharedApplication().keyWindow!)
}
else
{
let appDel = UIApplication.sharedApplication().delegate as? AppDelegate
actionSheet.showInView((appDel?.window?.rootViewController?.view)!)
}
Which currently displays the actionsheet like this:
How can I make it so the cancel button is the last button on the list?
Thanks :)
I feel that there's a very simple answer to this:
You can use destructiveButtonIndex to set the index of the destructiveButton to wherever you want.
actionSheet.destructiveButtonIndex = 2;