Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

StefanDevil

macrumors member
Original poster
Jul 31, 2010
38
0
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:

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

when click, launch action sheet:
Code:
- (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:

Code:
- (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. :)
 

ianray

macrumors 6502
Jun 22, 2010
452
0
@
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

macrumors member
Original poster
Jul 31, 2010
38
0
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!!!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.