我有一个“再次”;-) 一个我无法解决的问题。
我的应用在 tableView 上启动。当我选择一个单元格时,我转到“detailView”。在此视图中,我以这种方式在工具栏上添加了两个按钮:
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];
一旦我点击垃圾桶按钮,我就会调用方法“popupActionSheet”来使“删除确认”弹出窗口出现:
-(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];
}
然后,当我单击 破坏性ButtonTitle:@"Confirm" 时,“确认删除”弹出窗口消失并调用:
- (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];
}
当我回到我的 tableViewController 时,弹出(“showActionsheet:@“Demand deleted”];“)出现。
如果我单击“确定”,我的应用程序会崩溃。如果我禁用此弹出窗口(“showActionsheet”)一切都很好。
就像当我回到 tableView 时,在“DetailView”中调用的弹出窗口不再存在。
感谢您的帮助。