UIActionSheet cancel button not dismissing actionsheet
Asked Answered
R

6

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?

Reinsure answered 18/12, 2011 at 8:16 Comment(0)
R
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.

Reinsure answered 18/12, 2011 at 8:31 Comment(0)
E
42

Try this

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

UIActionSheet cancel button strange behaviour

Eightfold answered 18/12, 2011 at 9:4 Comment(1)
@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 buttonTurley
H
14

This Will do the trick

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

instead of

[actionSheet showInView:self.view];
Heuser answered 11/5, 2012 at 17:57 Comment(0)
V
4

use

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

instead of

[actionSheet showInView:self.view];

this is working fine.. :-)

Voile answered 22/8, 2013 at 10:48 Comment(0)
R
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.

Reinsure answered 18/12, 2011 at 8:31 Comment(0)
W
0

write simplite code

 actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

this work fine

Wharf answered 4/7, 2012 at 11:35 Comment(0)
T
0

I found the answer here.

https://mcmap.net/q/413598/-fitting-a-uidatepicker-into-a-uiactionsheet

[menu sendSubviewToBack:pickerView];
Transformation answered 1/4, 2013 at 5:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.