iOS white screen debugging - ios

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?

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.

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.

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.

ios8 UIModalTransitionStylePartialCurl doesn't work properly

Under ios 8 using presentViewController modalTransitionStyle = UIModalTransitionStylePartialCurl disappear all page.
I want it to work like ios 7.
I had the same issue and I applied this fix, it worked for me on iOS 8 and Xcode 6.
[_mapToolbarController setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[self presentViewController:_mapToolbarController animated:YES completion:^{
[_mapToolbarController.view.superview addSubview:self.view];
}];
Obviously, _mapToolbarController will be the controller that you want to present. To see why you'd need this, add a breakpoint at the line in the completion handler. Do the animation, and you'll see in the completion handler that the curling animation had just finished and everything was perfectly fine. For some reason that I can't explain, in iOS 8 you'll need to tell the iOS framework to "keep" the curled view and make sure it doesn't get thrown away. The code in the completion handler tries to "keep" the soon-to-be-faded curled view onto the screen. Note that in this context, self.view is the view that is being curled.
You can always try to make your own transitions with iOS 7. Have a look HERE
Well, I am not proud of the fix I came up with but it works just fine and took me little time to do it.
I managed to get a screen shot of the page curl at the stage that I wanted it to remain. It took a few tries but I got it. Then I took that image into Pixelmator and cropped it to just the page curl portion, made everything else transparent, smudged out the extraneous artifacts like the battery indicator, signal bars and time.
I imported that image in 320, 640 and 960 widths then insert it at the top of my presented view at load time. It came out virtually perfect. I cannot tell the difference from what I had before. Works exactly as I wanted it.

UIImagePickerController Showing Black Preview Screen

I am having a problem when calling the UIImagePickerController to use the camera. Sometimes, but more often than none, the preview screen shows to be black (as the camera itself is covered). After doing some research, it seems that people where not delegating it correctly..however, I believe my set up is correct. A restart of the app is what fixes it.
In my .h file I have included UIImagePickerControllerDelegate and UINavigationControllerDelegate.
Here is the code for the .m file
- (IBAction)camera:(id)sender {
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
#if TARGET_IPHONE_SIMULATOR
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
#else
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
#endif
imagePickerController.editing = YES;
imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:nil];
}
Any ideas as to why this is happening?
Thank you
I just fought this issue for a day and a half, sure enough I was doing something UI related outside the main thread. In my case I was updating a label in the response handling code for an asynchronous web service call.
In an app with several view controllers that have 2000+ lines of code each in them, this kind of thing can be very difficult to track down. This is what finally brought me to my answer, and VERY quickly at that.
https://gist.github.com/steipete/5664345
This guy posted a class you can download and add to your project. Simply add it to your project, you don't need to use it anywhere or try to instantiate anywhere, just add it to your project. He also states that you should run this without ARC. To do that, go to your Build Phases tab, expand Compile Sources, double click on the file and then type -fno-objc-arc
Now, run your project and navigate to where you are experiencing the black image preview screen. If all goes to plan, at some point prior to that your app should crash and dump to console some information about performing a UIKit action outside the main thread. Based on what your app was doing and what was dumped to console, you should be able to very quickly find the line of code causing you troubles. In my case I was able to call my response handler with a
[self performSelectorOnMainThread:#selector(handleResponse:) withObject:data waitUntilDone:true];
and my problem was gone immediately
Also, this issue only began once I updated to iOS 7, I never saw this in iOS 5 or iOS 6.
The guy who posted the file advises that you do not ship your app with this file included in your project and I strongly agree with that.
Happy debugging!
Try this. it solved my problem, make sure that there is a value
(Application name as string) in your info.plist > "Bundle display name".
In my case it was empty and because of that it didn't work.
If "Bundle display name" is not there in the info.plist,then add a row named "Bundle display name" and paste your appname .
Test this in your device. I think you are testing it in simulator and allowsImageEditing property Deprecated in iOS 3.1 so dont use it .
This can happen when there is animation not started on the main thread going on in parallel to kicking off the imagePickerController
If this is what you are running into you will likely see
<Warning>: CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces.
On your console log
I ran into it first by kicking off an activity indicator from a different thread (bug in its own right I know). But more insidiously this hit me due to loading a nib file in a background thread (which calls [CATransaction setDisableActions:] ... who knew)
Turning on CA_DEBUG_TRANSACTIONS in your scheme and then running in your simulator while tailing the system log (tail -f /var/log/system.log) is really the best way to find out the specific culprit.
Try this...
dispatch_async(dispatch_get_current_queue(), ^(void){
imagePicker.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
} ) ;
While it could be an issue that depends on many factor, as shown from the successful solutions provided by other members, I think it's worth mentioning the fact that the user might have denied permissions for camera usage (Under Privacy->Camera->Your application) and thus the camera shows, but displays a black preview screen. It just happened to me, and it depended from a bug in the early development stage in which that question was never seen by the user because of overlapping alerts.
When you're creating the UIImagePickerController change the cameraOverlayView to nil. It worked like a charm for me.
self.imagePickerController.cameraOverlayView = nil;
And that should be it.
Please check [UIApplication sharedApplication].keyWindow.frame

Resources