English 中文(简体)
IDViewController被正确地处理,但其观点并不正确?
原标题:UIViewController is correctly dealloced but its UIView is not?

我正在使用 Apple果工具“地点”工具,并且注意到,在我回头提出两种观点时,分配总是在增加。 在调查中,我发现,所有记忆都来自我方言中方言。

我接受检查,我的《国际调查评论》正在处理中,但看来《国际调查意见》不是吗? I m 不再保留统一意见书控制员的意见。 没有人有什么想法?

我在此写道,要改变观点。

UISubViewController *viewController = [UIViewControllerFactory createViewController:viewControllerID];     // Creates and returns a UIViewController by ID

[currentViewController viewWillDisappear:YES];
[currentViewController.view removeFromSuperview];
[currentViewController viewDidDisappear:YES];

[viewController viewWillAppear:YES];
[self.view insertSubview:viewController.view atIndex:0];
[viewController viewDidAppear:YES];

self.currentViewController = viewController;
[viewController release];

Edit:
Ok, because there was concern that I was just using a ViewController s View and then releasing the ViewController, I tried an experiment where I made a new class that is the File s Owner in the NIB, but inherits from NSObject.

该法典现在看着这一点:

MyView *myView = [[MyView alloc] initWithNibName:@"myView"];

[currentView viewWillDisappear:YES];
[currentView.view removeFromSuperview];
[currentView viewDidDisappear:YES];

[myView viewWillAppear:YES];
[self.view insertSubview:myView.view atIndex:0];
[myView viewDidAppear:YES];

self.currentView = myView;
[myView release];

我的初衷是:

@interface MyView : NSObject {
    IBOutlet UIView *view;
    NSArray *nibTopLevelObjects;
}

@property (nonatomic, retain) UIView *view;

- (id)initWithNibName:(NSString *)nibName;

@end


@implementation MyView

@synthesize view;

- (id)initWithNibName:(NSString *)nibName {
    if (self = [super init]) {

        nibTopLevelObjects = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil];
        [nibTopLevelObjects retain];
    }
    return self;
}

- (void)dealloc {
    [view release];
    [nibTopLevelObjects release];

    view = nil;
    nibTopLevelObjects = nil;

    [super dealloc];
}

@end

我仍然看到,我每次交换和发表新看法时,都发现了对观点的记忆泄露。

任何新想法?

问题回答

Your factory returns a viewController but you are only adding a view, not pushing a new controller. Why not just create a view in this case?

你们正在做的是,在不释放他们的情况下,不断推翻了自己。 你也许可以发表这一看法的控制者所持有的观点,但毕竟如此。

现任书记官

@property (nonatomic, retain) UISubViewController* currentViewController;

或许? 如果是这样的话,那就保留了一条与释放相对应的 is子,那么你就永远不会释放自己。 如果您不使用<代码>本身,则即使对财产作了如此界定,也不会保留。

你正确地删除了旧观点,并增加了新的观点。 这意味着,在您的《分意见》中,要么在其他地方,你错误地保留了观点,要么在模拟器中重新测试,而不是测试装置。

您能把《子号》交给一位子书记员,看看那里发生什么情况?

当你测试真实装置时,你是否取得了同样的结果?


PS Adam Eberbach提出了一个公平的观点,这就是为什么你只是为了偷窃观点而制造一种观点控制器,然后将其释放?





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签