我有 2 个视图,名为 viewcontroller1,viewcontroller2。每个视图控制器都加载了大约 3 张图片(在 XIB 中加载),当我尝试使用 [self.navigationcontroller pushviewcontroller] 将 view1 推送到 view2 时,内存无法释放。(我想知道它无法释放 viewcontrler1 或无法释放 uiimageview )我的代码有任何错误吗?
viewcontroller1 代码就像这样:
视图控制器1.h
@interface ViewController : UIViewController
@property(strong,nonatomic)IBOutlet UIImageView *mainImageView;
@property(strong,nonatomic)IBOutlet UIImageView *topwallImageView;
@property(strong,nonatomic)IBOutlet UIImageView *buttonImageView;
视图控制器1.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
self.mainImageView = nil;
self.topwallImageView = nil;
self.buttonImageView = nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
}
-(void)dealloc
{
[mainImageView release];
[topwallImageView release];
[buttonImageView release];
[super dealloc];
}
-(IBAction)main2ViewController:(id)sender
{
Main2ViewController *main2ViewController =[[Main2ViewController alloc]initWithNibName:@"Main2ViewController" bundle:nil];
[self.navigationController pushViewController:main2ViewController animated:NO];
[main2ViewController release];
}