presentViewController shows empty View - ios

I have been trying to present a view controller on my app but whenever I present it, it gives me an empty view. I have searched a lot on the internet and the StackOverFlow but none of the solutions are working for me. Here is my code:
In my viewWillAppear, I am calling the method:
[self performSelector:#selector(presentConfirmationView) withObject:nil afterDelay:0.4];
and here is the definition to the presentConfirmationView:
ConfirmRegistrationViewController *confirmationRegistrationController = [[ConfirmRegistrationViewController alloc] initWithNibName:#"ConfirmRegistrationViewController" bundle:Nil];
[self presentViewController:confirmationRegistrationController animated:YES completion:NULL];
Any idea why this might be happening? BTW, I am using Xcode 5.0.2.
I have tried to shift the code to viewDidAppear as well but to no avail.

When this happened to me (Xcode 6.4, iOS 8.4 simulator), the fix was to delete the app in the simulator and also delete my Build folder (I guess a Product->Clean command might also have worked).

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.

Xcode 7 navigationcontrller issue

I am facing some kind of issue in my when I compile my code with xcode 7.
Here is my code:
UIViewController *vcSomeObj = [self.storyboard instantiateViewControllerWithIdentifier:#"vcSOmeClass"];
vcSomeObj.channelID = detailOfUserTable.ID;
[self.navigationController setViewControllers:#[vcSomeObj] animated:NO];
This is working fine when I compile and run my code from xcode6.4.
This thing hang my application. And when I goes to any app and come agian to my app it will take to main controller and after sometime app crashes.
I can't find anything in debug.
In storyboard file We need to select English check box also otherwise application will hang an crash.
In my opinion.you set the current navigation's viewcontroller.what's happen to current viewController in navigation stack when you in current viewController,so ,I guess you can do like this
[self.navigationController setViewControllers:#[vcSomeObj,self] animated:NO];

WKWebview fail to open WKActionsSheet on presented UINavigationController

I have a problem with my WKWebViewController.
I use this code to present:
SRWebWKViewController *webcontroller = [self.storyboard instantiateViewControllerWithIdentifier:#"SRWebViewControllerWKWebview"];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:webcontroller];
[self presentViewController:navController animated:YES completion:nil];
It is presented correctly, but when I press on any link I get this error:
Warning: Attempt to present <WKActionSheet: 0x7fc4f4c6f5e0> on <UINavigationController: 0x7fc4f4b9d9e0> whose view is not in the window hierarchy!
I searched a lot on the web but I can not find any solution that solves my problem
Thanks in advance
This is a bug in UIKit from iOS 8.0 until at least iOS 9.3.1.
We've seen this issue in PSPDFKit and after investigating the UIKit assembly and WKWebView sources we found a workaround that is still horrible, but not invasive.
The main strategy is to be selective and apply a workaround just in time - then clean up again. You can read the source code here:
https://gist.github.com/steipete/b00fc02aa9f1c66c11d0f996b1ba1265
And please dupe rdar://26295020 so this will get hopefully fixed in time for iOS 10. (The bug exists since iOS 8 and was first reported on iOS 8b5.)

popToRootViewControllerAnimated crashes App in Xcode5 on IOS 7 sim

I have an issue with upgrading to Xcode5. Before I even set about changing anything in my project I thought I would build and run it with the IOS7 3.5inch Simulator. There are two major issues and this is the main one that I cannot figure out. I have identified a line of code that has always worked perfectly until now - now whenever it runs my app crashes with an EXC_BAD_ACCESS
I've traced it to a single line of code which is my popToRoot - basically at the end of filling out a form and saving it I want to reset the view to defaults which is what I have successfully used this line of code for until now.
The code looks like this:
[self.navigationController popToRootViewControllerAnimated:NO];
With some NSLog'ing in it looks like this:
NSLog(#" self.navCon is %#", self.navigationController);
NSArray *myControllers = self.navigationController.viewControllers;
NSLog(#"myControllers Content is %#", myControllers);
NSLog(#"myControllers Count is %i", myControllers.count);
[self.navigationController popToRootViewControllerAnimated:NO];
And my log out put looks like this:
2013-11-10 00:21:32.480 trainForTri copy[9552:a0b] self.navCon is <UINavigationController: 0xb5bf580>
2013-11-10 00:21:32.481 trainForTri copy[9552:a0b] myControllers Content is (
"<SGK_T4T_01SecondViewController: 0xbaeac00>",
"<AddSessionSessTypePicker: 0xb5e51e0>",
"<SGK_T4T_01SecondViewController: 0xbb5fa00>"
)
I have noticed that the 1st and 3rd viewControllers in my viewController array are the same view, but then why has it worked on all OS's until now? And more importantly any ideas on how I can fix this?
have you used arc ?
check your summary settings in xcode 5.anything can be changed.
problem with released object of your view controller
Please see if you are following these points:
Before calling popToRootViewControllerAnimated: confirm that the RootViewController does actually exist. If it died somewhere along the line, calling the method will cause a crash.
Check the – viewWillDisappear: and – viewDidDisappear: methods of your last view to make sure you're not doing something dangerous there.
Check the dealloc method of the views and their controllers to make sure your not over-releasing something.
Try to use NSZombie and find out the over-released object.

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