开发者

how to release presentModelViewController stack in iphone?

开发者 https://www.devze.com 2022-12-21 01:32 出处:网络
I m Copying my code here below :- -(IBAction)referencewindow:(id)sender { frmReferences *reference = [[frmReferences alloc]initWithNibName:@\"frmReferences\" bundle:nil];

I m Copying my code here below :-

-(IBAction)referencewindow:(id)sender
{
    frmReferences *reference = [[frmReferences alloc]initWithNibName:@"frmReferences" bundle:nil];
    [self presentModalViewController:reference animated:YES];
}

There are number of places I m using presentModelViewController and my probl开发者_JAVA百科em is that stack shows memory leakage due to presentmodelviewcontroller.

when we use presentModelViewController to call other nib as above stated then it just override to the previous view but previous view is still in process thats why memory lekage problem is occuring so please tell me when i call other nib file using presentModelViewController then how to unload that previous view from memory while switch to other view and then on other view to next view.


You must release your viewController after call the presentModalViewController method like here:

- (IBAction)referencewindow:(id)sender {
   frmReferences *reference = [[frmReferences alloc]initWithNibName:@"frmReferences" bundle:nil];
   [self presentModalViewController:reference animated:YES];
   [reference release];
}

There is more information here: Modal View Controllers


Your building a navigation hierarchy using present modal view? It could work but you need to released it sometime.

I think if you tried using normal memory management rules it would work out. Try going back from your views and they should be released, you'd see the memory go down in instruments.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号