Reputation: 387
I have a UIImageView
which is displayed using the following code:
profileImage = [self getImageFromUrl:@"http://i.imgur.com/l0HVdmR.png"];
if (profileImage == nil) {
NSLog(@"SourceImage is nil");
} else {
NSLog(@"SourceImage isn't nil");
}
profileImageView = [[UIImageView alloc] init];
profileImageView.image = profileImage;
[profileImageView setFrame:CGRectMake((screenWidth/2)-(profileDiameter/2), profileDiameter/2, profileDiameter, profileDiameter)];
[profileImageView setContentMode:UIViewContentModeScaleToFill];
profileImageView.userInteractionEnabled = isEditing;
NSLog(@"Online image used");
if (profileImageView == nil) {
NSLog(@"ImageView is nil");
} else {
NSLog(@"ImageView isn't nil");
}
Later on I use the code [mainScrollView addSubview:profileImageView
to add the UIImageView
to the UIScrollView
I have set up. The UIImageView used to correctly display this image without any trouble. However, the UIImageView
has suddenly stopped displaying altogether, and I'm unsure of what change elsewhere in my code caused this.
The framing isn't to blame. The variables are the correct values and changing them didn't solve the issue. The NSLog
s show both the UIImage
and UIImageView
to not be nil
. If it helps, the UITapGestureRecognizer
I have set up on the UIImageView
does not register taps in the area in which the image should be - This may provide some clue regarding the symptoms of the bug.
All help appreciated.
Upvotes: 0
Views: 49
Reputation: 566
Check whether the value of profileDiameter
was initialised or not. Also addSubview
must be used.
Kindly upload some more details regarding how profileDiameter
is found out.
Upvotes: 1