I'm debugging a problem with an imageView not being shown.
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
NSLog(@"imageView right after initialization is: %@", imageView);
imageView.frame = CGRectMake(2, 0, 316, 45);
imageView.layer.zPosition = zPos;
NSLog(@"imageView after running the setters: %@", imageView);
[self.view addSubview:imageView];
The weird part is that sometimes the imageView
gets displayed, sometimes it's not (about 75% of the time it's displayed).
imageView
is not accessed anywhere except the code above.
What I noticed is that when the imageView
is not displayed, the first log statement shows that:
imageView right after initialization is: <UIImageView: 0x9eaa760; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = <CALayer: 0x9ec04a0>>
When the image view is displayed:
imageView right after initialization is: <UIImageView: 0xaa61ad0; frame = (0 0; 644 88); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xaa61330&rt;&rt;
EDITED: I ran tens of tests, the imageView always behaves the same: when it is not shown, the initial frame is (0 0; 0 0). When it's not, it's always some other value.
P.S. I'm not using ARC.