UIActionSheet cancel button not dismissing actionsheet

TheLearner picture TheLearner · Dec 18, 2011 · Viewed 9.6k times · Source

I have an UIActionSheet and I am specifying the cancel button however it does not dismiss when its tapped?

UIActionSheet *actionSheet = [[[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Target Complete" otherButtonTitles:nil] autorelease]; 
[actionSheet showInView:self.view];

According to the documentation I don't need any code and even when I try and implement the didCancel delegate method its never called?

Answer

nevan king picture nevan king · Dec 18, 2011

Try this

[actionSheet showInView:[self.view window]];

UIActionSheet cancel button strange behaviour