我有一个 UIViewController 子类 ABCViewController。在长按按钮时,我打开一个包含 UIViewController(AddProduct) 的 UIPopover 在 abuton 长按时。添加产品包含一个取消按钮,可将用户带回 ABCViewControl.and 在仪器分配工具中它也消失了.罚款到这一点。像这样的事情..
-(void)openProductPopUp:(int)productId action:(BOOL)action{
AddProduct *addproduct = [[AddProduct alloc] initWithNibName:@"AddProductNew" bundle:[NSBundle mainBundle]];
[addproduct setProductId:productId];
[addproduct setIsAddingProduct:action];
UINavigationController *nav = [[UINavigationController alloc]
initWithRootViewController:addproduct];
[addproduct setDelegate:self];***//weak in add product***
[addproduct setDatabasePath:databasePath];
[addproduct setBackTracker:nil];
[addproduct setArrCategories:self.arrCategoryForPopUp];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:nav];
popover.delegate = self;
[popover setPopoverContentSize:CGSizeMake(576 , 490) animated:NO];
[popover presentPopoverFromRect:CGRectMake(512, 430, 1, 1) inView:self.view permittedArrowDirections:0 animated:YES];
self.popOver=popover;
[addproduct setPopUp:popover];***//weak in add product***
addProduct = YES;
}
AddProduct 包含一个编辑按钮,该按钮打开一个单独的 uiviewcontroller(AddProductSeparateViewController)。它 (AddProduct) 还包含一个取消按钮。单击取消按钮时用户返回 ABCViewCintroller。
**问题:**AddProduct 是在此过程中发布,但 AddProductSeparateViewController 没有根据分配工具的活动对象和 dealloc 断点发布。
AddProduct 中打开 AddProductSeparateViewController 的代码如下:
-(IBAction)Edit:(id)sender {
[delegate openEditProductPage:self.productId action:NO];
}
这个委托基本上通知 ABCViewController 打开 AddProductSeparateViewController。
-(void)openEditProductPage:(int)productId action:(BOOL)action{
[self.popOver dismissPopoverAnimated:YES];
[self openAddEditProductSeparatePage:productId action:action];
}
-(void)openAddEditProductSeparatePage:(int)productId action:(BOOL)action{
[self.searchBar resignFirstResponder];
self.isSalesVuOrderScreenHidden = YES;
[self setControlVisibility:YES];
btnClockIn.hidden=YES;
btnLogout.hidden=YES;
[btnBack.titleLabel setHidden:NO];
self.viewController = [[AddProductSeparateViewController alloc] init];
[self.viewController setProductId:productId];
[self.viewController setSalesVuScreen:self];
[self.viewController setIsAddingProduct:action];
[self.viewController setDelegate:self];
[self.viewController setDatabasePath:databasePath];
[self.viewController setBackTracker:nil];
[self.viewController setArrCategories:self.arrCategoryForPopUp];
[self.viewController.view setFrame:CGRectMake(0,48,1024,self.view.frame.size.height-48)];
[self.view addSubview:self.viewController.view];
}
AddProductSeparateViewController 中要取消的代码如下:
-(IBAction)cancel:(id)sender {
[self.view removeFromSuperview];
}
为什么 AddProductSeparateViewController 在这个过程中没有释放。
谢谢