12

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?

jrturton
  • 118,105
  • 32
  • 252
  • 268
TheLearner
  • 19,387
  • 35
  • 95
  • 163

6 Answers6

42

Try this

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

UIActionSheet cancel button strange behaviour

Community
  • 1
  • 1
nevan king
  • 112,709
  • 45
  • 203
  • 241
  • @nevan king: This is not work for me then I didnt use any tabbar or taskbar. I m using navigation then how can I dismiss with Cancel button – TamilKing Oct 29 '13 at 06:31
14

This Will do the trick

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

instead of

[actionSheet showInView:self.view];
hac.jack
  • 586
  • 5
  • 13
4

use

[actionSheet showFromTabBar:[[self tabBarController] tabBar]];

instead of

[actionSheet showInView:self.view];

this is working fine.. :-)

Amitabha
  • 1,664
  • 1
  • 12
  • 30
3

You need to display from a taskbar or a toolbar on iPhone as it clips some of the controls if you use display in view.

TheLearner
  • 19,387
  • 35
  • 95
  • 163
0

write simplite code

 actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

this work fine

jayesh kavathiya
  • 3,531
  • 2
  • 22
  • 25
0

I found the answer here.

https://stackoverflow.com/a/1530259/1803218

[menu sendSubviewToBack:pickerView];
Community
  • 1
  • 1
Read Q
  • 1,405
  • 2
  • 14
  • 26