UIImageView in appDelegate displayed in simulator, but not on device - ios

I've got a weird problem: I want to have a icon in one of my apps that stays above every other Controller/View. My idea was to create a UIImageView in the main XIB-File (the project started pre-iOS-5) above the UITabBarController that handles the Content Views.
I added the ImageView in the didFinishLaunchingWithOptions of the appDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
// Add the icon view that shows current working status (working/pause)
[self.window addSubview:self.statusIcon];
...
}
Initially the ImageView is hidden, it will only be shown when a button is pressed. Then i will assign the UIImage and unhide it:
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.statusIcon setImage:statusIconWorking];
[delegate.statusIcon setHidden:NO];
This works in the simulator, but not on a device (tested it on iPod touch 4. generation and iPad 3. generation (retina)).
Could someone please tell my it doesn't work that way? It's not a image problem (it exists on the device, and i tried to load other Image in the ImageView that are displayed correctly in other parts of the app).
Thank you.

I observed the same problem once and did not find a solution here. Some hints were helpful though, so I finally nailed it down. It happened only once and I noticed it some days after an xcode version change. However, I never found out what the solution was and if that was really caused somehow by the version migration.
The reason was that the image file was not part of the bundle. Check your boundle settings. Do so for every target that you may have.
My observation was: The image file was included in the bundle on the simulator. It did not only remain there from one version to the next. It was re-installed even when I removed the app from the simulator. I did so either removing it using the simulator's gui as if removing from a real device and I manually removed it from the simulator's file system - just to be sure. In any case the file was re-installed.
On the device it was different. Create an IPA or APP bundle as if you would do for beta testers of for submitting to the store. Have a look into it. (Changing the file name to .zip and unzipping may help to look into the bundle.) I bet that you will not find your image there.
Solution: doublecheck your project settings and ensure that all resources are properly included for all targets respectively.

Related

Black screen on app launch after latest Xcode 7.2 update

i am making a very complicated app with a lot of classes.
my app worked great and i worked on it for the last month.
the last time i worked on it i added a function and it worked great, i saved the app and ran it a few times since and it worked. the last time i turned my computer on, it prompted me that an update for xcode is available. i updated it, and since then every time i run my app it runs with no errors but on ios simulator it shows a black screen. what can i do? i worked really hard on that app. thanks for the help in advance.
There's few issues that could happened, withou detailed description of this issue, you can try following solutions:
reset simulator
check if your initial controller is set up in storyboard(select controller and press attribute inspector, select is initial view controller):
if you're setting initial view controller programmatically, check if that controller is not nil in app delegate
another tip - try to use UI debugger, that helps a lot:
Any debug messages in the Xcode output? That usually will give a clue.
One thing I can think of, is that in your
- (void) applicationDidFinishLaunching:(UIApplication*)application
delegate, try setting the window's root view controller to your view controller. Example:
[window setRootViewController:viewController];
[window makeKeyAndVisible];
Again, the Xcode debug output will confirm if this is indeed the case though.

Image does not update in Launch Storyboard

I have noticed that if I change an image in the xcassets, the launch storyboard does not update.
For instance, let's say you have a UIImage view in your launch storyboard with an image called "logo" that is blue. If you open up the in the Finder and change the color of the image to red, next time you run on the device the logo will still be blue.
The preview of the storyboard in xCode will show the correct (red) logo image.
Before running, I have tried:
Cleaning the Project
Deleting Derived Data
Deleting the App
Renaming the Image
Nothing seems to fix the problem. Is there another option that I am missing?
Appears to be a problem with caching on the device. Delete your app, restart the device, and pray. Image does not update when changed if that image is used on LaunchScreen.storyboard
Exiting out should normally solve the job... Sometimes, especially in the playground I have heard and experienced, it will not automatically refresh and you can either:
Wait a tiny bit(in most cases) but it seems you would not be asking if it were a few seconds of delay so maybe try
Deleting everything associated with that image(the outlet reference, image on storyboard, and any time you use that image in you code(leave those spaces blank)), then create a new UIImageView and assign it to your desired image.
In your Images.xcassetts file you may have only changed the info on one of the sizes; make sure those are all set.
Then again, especially after the most recent WWDC, there have been some bugs in Xcode that will need to be patched in the future. At the least, I hope this helps you and people who view this in the future.
I tried deleting the app from device while also deleting the derived data and cleaning, but it seems that you have to restart the device. That is the only thing that worked for me.

iOS white screen debugging

Sometimes, when I run app, I got white screen. But I know app is still running (coz I need to play sound).
Somehow, the view hierarchy mess up I guess. Problem is that I never see white screen if I run from Xcode. If I see, I will know how is the hierarchy.
dispatch_async(dispatch_get_main_queue(), ^{ //need to run in main thread.
self.window.rootViewController = self.defaultVC;
[self.window makeKeyWindow];
self.window.hidden = NO;
});
Is it because of view hierarchy? Or any other reason which can produce white screen?
There is an awesome little tool called PonyDebugger which enables view-based debugging. You just throw it all in your project and start it in your AppDelegate and you can see at anytime exactly what view is displayed.
You can basically step through the hierarchy like in "chrome F12".
This helped me solve WhiteScreen-problems in the past.
Check your Copy Bundle Resources (found within Build Phases) and make sure that all of your .xib files are correctly listed (e.g. that they are indeed there).
Also is there a specific reason you are creating that window programmatically instead of using setRootViewController?

What's causing the massive changes in autorotation in 8.1 compared to 8.0.2?

I'm coding a video processing app and was just about to submit it to the app store when ios 8.1 came out. I updated my iPhone as well as XCode and all hell broke loose. In my simple single viewcontroller interface nothing is rotating anymore except for the statusbar, which also doesn't get automatically hidden anymore in landscape mode...
I figured it was because I was using the deprecated willAnimateRotationToInterfaceOrientation: for what little custom rotation actions I had, so I implemented traitCollectionDidChange: and viewWillTransitionToSize: to specs instead. However viewWillTransitionToSize never gets called in my app and traitCollectionDidChange: is only called once, at startup. The device simply isn't telling the app that the device has rotated.
After googling I've also tried using name:UIDeviceOrientationDidChangeNotification. At least my selector does get called for that one but I don't know how to manually handle all rotation.
My didFinishLaunching... and viewDidLoad are very simple. alloc UIWindow, storyboard, set my viewcontroller from there, make it rootviewcontroller, makekeyandvisible. All based on one of Apple's AVFoundation demo apps.
Then in didload I add some subviews and a toolbar etc, nothing out of the ordinary and obviously it did work on 8.0 and 8.0.2 on all kinds of devices as well as the 7.1 simulator etc. Still runs flawlessly on my iPad with 8.0.2... Reason I haven't posted any code is I'm 100% sure everything is correct on that end.
Main weird thing is I can't seem to find anyone with this problem.
No errors in console or elsewhere either.
Does anyone have any idea of what might be causing this? I didn't think a point release would make such massive differences and again, no one else seems to be having this. Could it be an issue/bug in the actual storyboard file?
And, mainly, since I can get rotation notifications through UIDeviceOrientationDidChangeNotification, how do I manually handle all rotation/resizing stuff? I have been looking all over for answers but to no avail and am out of time to spend on this project currently :(
Cheers!
alloc'ing UIWindow will be the problem.
First, Make sure your navigation controller (or whatever you're using) is set as "Initial View Controller" in your storyboard.
Secondly, in your AppDelegate.m file, remove any references to UIWindow and rootViewController that appear in application didFinishLaunchingWithOptions. In my case, removing the following two lines fixed my issues.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];
You also don't need to set the window's rootViewController if using storyboards.
They're simply not needed when using storyboards, but until 8.1 there was never any harm using them. It took my 2 days to figure this out, so hopefully it will help you and others too.

Image being loaded before app main method is called

I have an ipad app where I am seeing an image displaying briefly before the app starts (image is part of bundle).
My guess is that this is some wrong wiring of a xib file, but even when I set a breakpoint at the beginning of the main method, the image still appears before this point is reached.
Resetting the simulator does not help, and the scenario occurs on a device too.
Mmmm is the image named Default.png ?
I just don't see an other explanation for this problem ^^
By the way, I just don't use Interface Builder to avoid this kind of strange problems ^^

Resources