Iphone SDK: UIView dealloc not called. What for?

I have a custom UIView called TiledImage that has one property named tiledImage and a custom drawRect method. I add this view to my ViewController, but when the ViewController is freed, dealloc is never called for this view, although I free the view and set it to nil. What could be the reason for this? I have no other links to the view, so I understand that it should be correctly released.

This is how I add a view to my view controller:

NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"tile" ofType:@"png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];

self.backImageView = [[TiledImage alloc] initWithFrame:IMAGE_FRAME];
self.backImageView.tiledImage = image;
[self.view addSubview:self.backImageView];
[self.view sendSubviewToBack:self.backImageView];
[image release];

And in my dealloc ViewController method, I have this:

_backImageView.tiledImage = nil, [_backImageView release], _backImageView = nil;

This line of code hits, but dealloc is never called in a TiledView. Note: _backImageView is a var that uses the backImageView property.

- , , dealloc TiledImage?

+3
1

self.backImageView retain, - TiledImage 1 , 2 .

. :

TiledImage *imageView = [[TiledImage alloc] initWithFrame:IMAGE_FRAME];
self.backImageView = imageView;
[imageView release];
+7

Source: https://habr.com/ru/post/1745164/


All Articles