UIImageView with iOS 7 not showing

I have an application that I created for iOS 6 that I recently upgraded to iOS 7. I have a UIScrollView with several Custom UIViews . Inside UIViews , I have one UIImageView in each. For some reason, when I installed UIImageView.image on iOS 6, it displays fine, but iOS 7 doesn't display them. Here is the code:

 int i = 0; for (UIImageView *imageView in myImageViewsOutletCollection) { imageView.image = nil; if (imagesArray.count > i) imageView.image = [UIImage imageWithData:[imagesArray objectAtIndex:i]]; if (imageView.image == nil) NSLog(@"signature image with index: %i is nil", i); else NSLog(@"It Worked") i++; } 

My application logs: @"It Worked" , so I know that UIImageView.image not nil . What can i do wrong?

EDIT:

I tried UIImageRenderingMode:

 UIImage *imageForView = [UIImage imageWithData:[imagesArray objectAtIndex:i]]; imageForView = [imageForView imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; imageView.image = imageForView; 

Still not working. However, @ Max_Power89 said:

as written on the Apple Developer Forum: error imageWithData Report

this is mistake. I hope they fix the problem sooner.

EDIT 2:

I also added:

 NSData *pngData = UIImagePNGRepresentation(imageView.image); NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *docs = [paths objectAtIndex:0]; NSError *writeError = nil; [pngData writeToFile:[docs stringByAppendingFormat:@"/image.png"] options:NSDataWritingAtomic error:&writeError]; if(writeError!=nil) { NSLog(@"%@: Error saving image: %@", [self class], [writeError localizedDescription]); } 

The image was saved in the application directory, so I know for sure that the image is not zero.

+6
source share
4 answers

This is a problem / error with automatic layout restrictions in iOS 7. If you remove the restrictions on UIView , this is not a problem. You can set frames programmatically if you need to.

+1
source

In iOS 7, the default download only downloads the alpha channel by default, and then colors it with the color of detail. Your image is displayed, just that it has the same color with the background.

 - (UIImage *)imageWithRenderingMode:(UIImageRenderingMode)renderingMode 

Set the value for this:

 UIImageRenderingModeAlwaysOriginal 
0
source

as written on the Apple Developers Forum: imageWithData error report

this is mistake. I hope they fix the problem sooner.

0
source

Perhaps this will be useful for everyone: I had the same problem - at least it looked like this. In the end, I realized that UIScrollView was hiding some layers of the background view. The background of the UIScrollView has been set to the " Background color of the table table " in the .xib file. If I changed this to β€œclear the color,” the behavior would return to normal (as in iOS 6). It seems that the "default behavior" has changed for this item from iOS6 to 7. Perhaps someone can confirm this.

0
source

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


All Articles