Hi guys,
I have a "again" ;-) a problem i can't solve.
My app launches on a tableView. When i select a cell, i go to the "detailView". On this view i add two buttons on the toolbar this way :
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 115, 44.01)];
// tab where buttons are stored
NSMutableArray* buttons = [[NSMutableArray alloc] init];
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStylePlain target:self action:@selector(nextEdit)];
UIBarButtonItem *btn2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(popupActionSheet)];
btn.style=UIBarButtonItemStyleBordered;
btn2.style = UIBarButtonItemStyleBordered;
[buttons addObject:btn];
[buttons addObject:btn2];
// add buttons to the toolbar
[tools setItems:buttons animated:YES];
// add buttons within "tools" to the view
UIBarButtonItem *btn3 = [[UIBarButtonItem alloc] initWithCustomView:tools];
self.navigationItem.rightBarButtonItem = btn3;
[buttons release];
[btn release];
[btn2 release];
[btn3 release];
[tools release];
Once i click on the trash button i call the method "popupActionSheet" to make "delete confirm" popup appears:
-(void)popupActionSheet {
isActiveSupr=(BOOL)YES;
UIActionSheet *popupQuery = [[UIActionSheet alloc]
initWithTitle:@"Delete ? "
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Confirm"
otherButtonTitles:nil ,nil];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[popupQuery showInView:self.tabBarController.view];
[popupQuery release];
}
Then when i click on destructiveButtonTitle:@"Confirm" the "confirm delete" popup dismisses and it calls :
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if(isActiveSupr==TRUE)
{
if(buttonIndex==0)
{
[self send_requestDelete];
}
}
}
- (void)send_requestDelete:
{
... //nothing to do with popup
[self showActionsheet:@"Demand deleted"];
[self.navigationController popToRootViewControllerAnimated:YES];
... // nothing to do with popup
}
-(void) showActionsheet :(NSString *)msg
{
UIActionSheet *popupQuery = [[UIActionSheet alloc]
initWithTitle:msg
delegate:self
cancelButtonTitle:@"OK"
destructiveButtonTitle:nil
otherButtonTitles:nil ,nil];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[popupQuery showInView:self.tabBarController.view];
[popupQuery release];
}
While i go back on my tableViewController the popup("showActionsheet:@"Demand deleted"];") appears.
If i click "OK" my app crashes. If i disable this pop up("showActionsheet") everything is fine.
It's like while i go back to the tableView , the popup which was called in "DetailView" doesn't exist anymore.
Thx for the help.