In my app, I need to display a splash screen.I collect the image from URL and saved it as Default.png in documents folder.
I successfully saved the image and collected the path.
My problem is that it is not displayed. I don't get any errors and in the log I got correct path too.
This is my code:
NSString *workSpacePath=[[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"/Default.png"];
imgView=[[UIImageView alloc] init];
imgView.image=[UIImage imageWithData:[NSData dataWithContentsOfFile:workSpacePath]];
[self.view addSubview:imgView];
I got correct path in workSpacePath.
Don't overwrite your image with the [UIImage imageNamed:] method. This method only works for images that are part of your bundle. It will return nil for the path in your documents directory. And because of that you set imgView.image nil. Which means, remove the image.
this should work:
NSString *workSpacePath=[[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"Default.png"];
imgView=[[UIImageView alloc] init];
imgView.image=[UIImage imageWithData:[NSData dataWithContentsOfFile:workSpacePath]];
//imgView.image=[UIImage imageNamed:workSpacePath];
[self.view addSubview:imgView];
But you can't replace the "real" splash screen. You can however show a different image after the original splash screen disappeared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With