PDA

View Full Version : Pressing Cancel button doesn't retract




StefanDevil
Aug 23, 2010, 02:56 AM
Hi there,

i implement an actionsheet, when press "ok" button, do these, press "cancel" go back. the "ok" button is working fine, but when i press the "cancel" button, nothing happens, it doesnt retract or do anything, just hang at the actionsheet view.

below is my code:

create button at nav bar:



UIBarButtonItem *clearButton = [[[UIBarButtonItem alloc] initWithTitle:@"Clear History"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(ClearHistoryAction:)] autorelease];
self.navigationItem.leftBarButtonItem = clearButton;


when click, launch action sheet:


- (IBAction)ClearHistoryAction:(id)sender
{
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"Clear History?"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"OK"
otherButtonTitles:nil];


// use the same style as the nav bar
actionSheet.actionSheetStyle = self.navigationController.navigationBar.barStyle;

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


}



if select ok do this:



- (void)actionSheet:(UIActionSheet *)actionSheet

didDismissWithButtonIndex:(NSInteger) buttonIndex
{
if (!buttonIndex == [actionSheet cancelButtonIndex])
{

//do what i want here!
}
}


at header file, UIActionSheetDelegate is included @ @interface.


thks for your time. :)



dejo
Aug 23, 2010, 09:54 AM
This code works fine. Must be something else you're doing.

ianray
Aug 23, 2010, 01:26 PM
It could be that the cancel button is obscured (in window Z-order) by a toolbar. This can be proven by attempting to click near-the-top of the cancel button -- if that works then you need to check UIActionSheet APIs that begin with "show"... Good luck :)

StefanDevil
Aug 29, 2010, 01:52 PM
It could be that the cancel button is obscured (in window Z-order) by a toolbar. This can be proven by attempting to click near-the-top of the cancel button -- if that works then you need to check UIActionSheet APIs that begin with "show"... Good luck :)

hey thats the problem!!, now how do i solve this..
solve!!! thks!!!

ianray
Aug 29, 2010, 05:16 PM
hey thats the problem!!, now how do i solve this..
solve!!! thks!!!

Cool. Check UIActionSheet APIs that begin with "show"... :D

blindjesse
Aug 30, 2010, 11:31 PM
Look here:

http://stackoverflow.com/questions/1197746/uiactionsheet-cancel-button-strange-behaviour