UIImage is not displaying - ios

I know it's a silly question. But I am not finding a way to solve this.
Image icon is located in Image assets (i.e. Assets.xcassets). It is being displayed if I run the application from Xcode (i.e. in debug mode). But it is not being displayed if I install the application from TestFlight (i.e. Release mode).
Here is my code for that.
somewhere in ViewDidLoad()
arriCon = [[NSMutableArray alloc]initWithObjects:#"home_icon",#"s_Internammatches_icon",#"InternalRating",#"s_tournaments_icon",#"s_EmailManagement_icon",#"s_Canteen_icon",#"Meeting_icon",#"s_event_icon",#"s_stats_icon",#"ic_poll",#"s_ourclub_icon",#"Album_icon",#"s_setting_icon", nil];
and somewhere in viewForHeaderInSection() (yeah, I've multiple headers in UITableView and in that, I'm displaying image)
headerView.imgiCon.image = [UIImage imageNamed:[arriCon objectAtIndex:section]];

Related

How To Load The Image Set(The Bundle) From Images.xcasset in iOS

When I am developing apps in iOS before, I always put the image sources of the app at the root directory of the project, and then I will load them using [UIImage imageNamed:#"image.png"]. I did't even include various sizes and resolutions such as image#2x or image#3x. But I am afraid this is not a good practice, because I cannot deal with different screen resolutions.
Now, I want to make use of the Images.xcasset to store all my image sources so that I will be able to load just the bundle name, and hoping that the system will pick the image with the right resolution automatically. Therefore, I made a test and place my image set under Images.xcasset and named it as images, and then in my UIViewController.m I am trying to load the image by calling [UIImage imageName:images]. As a result, it didn't work. So I searched for an answer and found out that I should call [UIImage imageName:#"images60x60#2x.png"] in order to load the the 60pt #2x image.
But I think this still did not solve my problem, because I am still choosing which image to load. Is there a way to load the entire image set or load the image according to the resolution of the screen?
Please help. Many Thanks.
EDIT: Added Screen Shots
I use AppIcon as a test
As you said at last that you are using AppIcon as a test. Please don't AppIcon it is made for internal use. try to create you own imageSet and use that. It should work.
Two things :
As said Ankit, do not use App Icon, use your own set
do not use a file suffix. Just reference [UIImage imageName:#"MyImage"] (not [UIImage imageName:#"MyImage.png"])

Unable to configure launch screen appearance using view controller file

I have a LaunchScreen.storyboard which serves as the launch screen file. In this storyboard is a view controller with the class LaunchViewController.
In my LaunchViewController.m file I changed the view's background color and added a label with the FB shimmering effect (https://github.com/facebook/Shimmer).
_shimmeringView = [[FBShimmeringView alloc] init];
_shimmeringView.shimmering = YES;
_shimmeringView.shimmeringBeginFadeDuration = 0.3;
_shimmeringView.shimmeringOpacity = 0.3;
[self.view addSubview:_shimmeringView];
_logoLabel = [[UILabel alloc] initWithFrame:_shimmeringView.bounds];
_logoLabel.text = #"Shimmer";
_logoLabel.font = [UIFont fontWithName:#"HelveticaNeue-UltraLight" size:60.0];
_logoLabel.textColor = [UIColor whiteColor];
_logoLabel.textAlignment = NSTextAlignmentCenter;
_logoLabel.backgroundColor = [UIColor clearColor];
_shimmeringView.contentView = _logoLabel;
But when I ran it there's only an empty white background displayed as the launch screen. Also I find that he LaunchViewController looks fine when used as a regular view controller. How to make it display the same effect when used as launch screen?
You can't use code inside a launch view controller nib. Whether it is a storyboard or a separate nib. The code is not executed. The only thing that works is what is in InterfaceBuilder like auto layout and stuff. No code is loaded. This would defeat the purpose of using a launch file. The launcfile is loaded before the app has had chance to load.
No app, no code. Only the launch file.
I've had similar problems, and based on your code, it may be similar to mine. First off, I don't understand your question as much as I would like to. You said, "The LaunchViewController works fine when not used as launch screen." Does that mean that it looks the way you want it to look like when viewing on Xcode, but not on the simulator? I will try to provide possible solutions, and some trouble-shooting tips.
It could be something as simple as your background(or something) is at the front of the screen, blocking the rest. If so, you have to reconfigure the order of your items on your launch screen in your xib file in your application.
It could be an error on your part. Some of my programmer friends develop their launch screens using the Xcode interface: I find that easier to use, and it may have less errors.
It could be an issue with the iOS simulator. This is not likely to be true, but it could be. Try running the app on your device and see if it is fine there.
Troubleshooting: In order to trouble shoot your code, comment out your code, and load in all the elements of your launch screen one at a time, checking the iOS simulator and the console in between. You will eventually find the problematic code, and be able to fix it. From looking at your code, I don't see anything wrong (but don't take my word on it, I'm not familiar with coding the launchscreen/storyboard in swift. Good luck, and I hope my tips work. Also, if your launch screen is appearing fine inside Xcode, it is a programming error or an error on the iOS simulator. A picture or a description of your launch screen could also help future people who will answer this question.

iOS App Issue - Can't access image from image asset catalog

I'm new to iOS development, so apologies for advance. I know this has been covered earlier but I can't seem to find anything that helps with my issue.
Its a fairly simple but annoying issue.
I have a image in assets with a file name of hollwood.png but a xcode name, "hollywood" (no png).
I am trying to set a UIImageView to display it.
So in ViewDidLoad I have the following: (imageContainer is the UIImageView IBOutlet)
- (void)viewDidLoad {
super viewDidLoad];
self.model = [Model sharedModel];
self.imageContainer.image = [UIImage imageNamed:#"hollywood"];
}
I can not get it to display the image from Assets.
I know the UIImageView outlet works correctly because I can have the app choose a photo from gallery and set the photo to UIImageView.
I'm having a very difficult time figuring out how to load the image I saved in the assets catalog into UIImageView.
I just had this issue. I had dragged the image and for some reason Xcode added a weird "Design" locale and I couldn't load the image using UIImage(named: ). I don't know if this is your case, but you can try right clicking on the image in the Asset Catalog, "Show in Finder", opening the folder and checking the "Contents.json" file. Each image there should only have the keys "idiom", "filename" and "scale".
Make sure your image is added in Compile Sources
AppTarget->Build Phases-> Compile Sources
If not try to add that and check.

Picture doesn't show on iPhone when running app

I have set the backgroundColor to a picture which is located in the project folder. When I run the app in the simulator the pic is shown. But when running on my real iPhone it's just white. What can be causing this? Could it be because I have <0.5gb free on both the computer and iPhone?
I had similar situation.
It seems the simulator - Xcode is cacheing the image somewhere, but at build time is loosing.
Try: uninstall the app from simulator, device.
Clean the project.
Force close XCode, not just the project, close it.
Open, clean project, build
At this step should match the device and simulator behaviour, hopefully it is there the desired image.
Please check spelling of the image name you used. In actual devices it's case sensitive.
That should be plenty of free memory. When adding the file to your project, and make sure you choose the options for the image to be copied into the project and to be part of the target.
EDIT: my above suggestion is only useful if the UIImageView you are trying to load points to a picture, and I guess in this case you are just using a blank UIImageView and setting background color.
Also, you might want to look at the arrangement (ie. send to back, send to front, etc. Try sending to front in case there was something in front of it blocking the view) I think these options are in the menu bar under Design --> Arrangement
Could you post some code?
You'll want to add the image not as a backgroundColor, but as a UIImageView subview.
// load the image
UIImage *image = [UIImage imageNamed:#"image.png"];
// create the image view using the image
UIImageView *imageView = [UIImageView alloc] initWithImage:image];
// add the image view as a subview
[yourview addSubview:imageView];
First try to Uninstall the app Clean the project then Install and then check if not then.
Second there may some issue with picture spelling Case senstive or Not As The iPhone is case sensitive, but the simulator is not because iPhone file system is case sensitive and Mac OS is not
Third
Add a break point where you add UIImage
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 100, 50)];
imgView.image = [UIImage imageNamed:#"a_image.png"];
Then on the console "po [imgView image]"
If it is nil then either the resource is not getting copied correctly into the bundle.

UIImage initWithData behaves differently on iOS 4.3

I have an app that's been running fine in the App Store for 6 months or so, but none of its images (downloaded from a web site via "NSURLConnection initWithRequest") show up in iOS 4.3. It turns out that I have a line of code that looks like this:
UIImage *img = [[UIImage alloc] initWithData:data];
and shortly thereafter, to get ready for the next image, I do this:
data.length = 0;
When I comment out setting the length to zero (deferring it until the download of the next image begins), it works on iOS 4.3.
I've checked carefully to make sure there's no buffer interference, but each of my images is in its own instance of an object that has the buffer (data) as an instance variable.
It seems to me that in iOS 4.3 the initWithData implementation is not completely finished with the data when the method returns. Perhaps some work is being deferred until the UIImage is assigned to the UIImageView, which happens a bit later? Maybe even deferred until the UIImage is rendered?
Can anyone shed light on this seemingly-new behavior in iOS 4.3?
I think your analysis sounds about right. It's easy to imagine the kind of small change that would cause this, for example UIImage may have been changed to retain the data rather than copy it, or something like that. I'd file a bug with Apple to make sure that someone notices the issue, and then work around it by changing your code to:
UIImage *img = [[UIImage alloc] initWithData:[[data copy] autorelease]];
At least, I assume that'd work around it. It'd be very interesting if it doesn't... please let us know one way or the other.

Resources