I created two action sheets in one view. There are two buttons, each will initiate one action sheet.
The problem: when i press on first choice in both action sheets the same action is triggered.
Here's my code:
-(IBAction) ChangeArrow:(id)sender{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Change Arrow"
delegate:self
cancelButtonTitle:@"cancel"
destructiveButtonTitle:@"Red"
otherButtonTitles:@"Blue",@"Black",nil];
[actionSheet showInView:self.view];
[actionSheet release];}
- (void) actionSheet: (UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{
if (buttonIndex ==[actionSheet destructiveButtonIndex]) {
self.bar.image=[UIImage imageNamed:@"red"];
}
else if(buttonIndex == 1){
self.bar.image=[UIImage imageNamed:@"blue"];
}
else if(buttonIndex == 2){
self.bar.image=[UIImage imageNamed:@"dark"];}
}
//Second Action sheet:
-(IBAction) Background:(id)sender{
UIActionSheet *actionSheet2 = [[UIActionSheet alloc] initWithTitle:@"Change Background"
delegate:self
cancelButtonTitle:@"cancel"
destructiveButtonTitle:@"Sky"
otherButtonTitles:@"Thumbs",@"Smiley",nil];
[actionSheet2 showInView:self.view];
[actionSheet2 release];
}
- (void) actionSheet2: (UIActionSheet *)actionSheet2 didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex ==[actionSheet2 destructiveButtonIndex]) {
self.background.image=[UIImage imageNamed:@"sky"];
}
else if(buttonIndex == 1){
self.background.image=[UIImage imageNamed:@"thumbs"];
}
else if(buttonIndex == 2){
self.background.image=[UIImage imageNamed:@"smiley"];}
}