I am trying to create a function which creates an actionsheet when called from different viewcontrollers. The issue is that although the uiaction sheet gets created, I can't seem to perform any of the designated click actions. Infact the delegate never gets called. On clicking any of the buttons the actionsheet is dismissed.
My code for the function is:
func shareAction(){
var sheet: UIActionSheet = UIActionSheet();
print("Calling share action!");
let title: String = "Tell friends, make plans";
sheet.title = title;
sheet.addButtonWithTitle("Cancel")
sheet.addButtonWithTitle("WhatsApp");
sheet.addButtonWithTitle("Facebook");
sheet.addButtonWithTitle("Message");
sheet.addButtonWithTitle("More");
sheet.cancelButtonIndex = 0;
sheet.delegate=self;
sheet.showInView(self.view)
}
func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int)
{
print("clicking the action sheet")
if(buttonIndex ==0){
print("this is 0")
}
This is inside a class which extends NSObject and UIActionSheetDelegate. I have gone through every bit of documentation and am stumped as to what is causing the issue.