UIViewController's viewDidAppear not being called after a modal close - uiviewcontroller

A UIViewController (View A) invokes another view controller (View B) by invoking it as a modal control.
[self presentModalViewController:ViewB animated:TRUE];
And View B exists by invoking:
[self dismissModalViewControllerAnimated:TRUE];
When this occurs everything looks right EXCEPT that View A's viewWillAppear and viewDidAppear does not get called (they are called during app init though). Weird thing is... i believe ive done this before, but im not sure what is going on now.
Is there anything obviously wrong that im doing?
Thanks!
* UPDATE *
I just now learned that this behavior only occurs with the UIModalTransitionStylePartialCurl transition type. For all other transition types the parent view-controller gets its viewDidAppear message just fine.
So now what am i suppose to do!?!

I just ran in to the same problem.
I solved it by adding a delegate and a delegate method.
So when Controller A opens Controller B as a modal view controller with a page curl i set the instance of controller b's.delegate to be controller a.
In controller B i add this:
-(void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if (delegate)
[delegate didCloseInfoViewController];
}

Related

transitionViewForCurrentTransition is not set error

Here is my project:
It only crashes in iOS8.
I have 5 view controllers:rootViewController,A,B,C and D.Every view controller has a button that present another view controller except D. Evert time presenting a view controller, the Manager singleton object will add the presented view controller into an array. The last view controller D, which has a dismiss button, will use the array to dismiss view controller,and here's the code:
while ([Manager sharedManager].viewCont.count) {
UIViewController *viewController = [[Manager sharedManager].viewCont lastObject];
[viewController dismissViewControllerAnimated:NO completion:nil];
[self removeViewCon];
}
But I meet a crash,which shows:
I use some manage object because I want to manage the view controllers in some case.
My question is why this crash occurs when in "while" statement? Is it about runloop or iOS8 has some features like UIPresentationController that will not allow this case? And how to fix this?
Thanks in advance.
I just hit this also. It seemes the UIPresentationController crashes if it's presenting view disappears before it is done using it. One fix is to keep the view controller around a little bit longer.

From ViewController to TabBarController

My initial VC is the LoginController. After the login a seque is going to a tabbar. This works fine but what I want is to check if the user is logged in to present the tabbar.
I put [self performSegueWithIdentifier:#"tabBar" sender:self];
in LoginController inside the viewdidAppear but is not nice because it shows the LoginView for a while. If put it inside the viewDidLoad is not working.
Any suggestions on how to solve it?

why is my viewcontroller not in the window hierarchy?

Using storyboards, MainMenuViewController presents Number1ViewController modally with this:
-(void) goToNumbers {
[self performSegueWithIdentifier: #"seguetonumbers" sender: self];
}
Then Number1ViewController presents Number2ViewController like this:
-(void)nextLevel {
[self performSegueWithIdentifier: #"segueToLevel2" sender: self];
}
xCode then produces this warning:
2013-01-23 12:09:49.873 ToddlerTeacherMini[7574:907] Warning: Attempt to present <Number2ViewController: 0x1fddc720> on <Number1ViewController: 0x1fdc7380> whose view is not in the window hierarchy!
Evertything I see online about this warning says that you cannot present a VC in another VC's viewDidLoad method and moving your code to the viewWillAppear method will fix this. Im not calling this segue from viewDidLoad but rather im calling it way later so Im not sure why this is happening.
I present VC's similarly elsewhere in my app without issue and cant figure out what is different here, any help?
To be clear everything appears to work as expected in my app I just dont want to ignore this message and have it come back and bite me later.
Per Todd Kerpelman's suggestion I looked into where my nextLevel method was getting called. Breakpoint didnt tell me much but digging a little further with NSLog I came up with this:
-(void)nextLevel {
if (nextLevelHasNotBeenCalled == 0){
[self performSegueWithIdentifier: #"segueToLevel2" sender: self];
NSLog(#"Segue was called here.");
}
nextLevelHasNotBeenCalled ++;
NSLog(#"Next level has been called %i times!", nextLevelHasNotBeenCalled);
}
Log:
2013-01-26 02:04:12.579 ToddlerTeacherMini[9203:907] Segue was called here.
2013-01-26 02:04:12.593 ToddlerTeacherMini[9203:907] Next level has been called 1 times!
2013-01-26 02:04:14.789 ToddlerTeacherMini[9203:907] Next level has been called 2 times!
Pretty clear now that nextLevel is getting called twice and is what is causing my problem.
This sounds like a case of your code accidentally calling nextLevel when you're not expecting it to. (Probably as a side effect of some unrelated method being called in your Number1ViewController's viewDidLoad method.)
Did you try adding a breakpoint to your nextLevel method and seeing how/where it's getting called? That's probably the best way to at least confirm (or eliminate) this possibility.

uiviewcontroller black

I've just created a storyboard with few table controllers and one view controller.
Everything works fine until my app push the view controller: it's shown completely black.
I can add map view, image view or whatever, or even nothing (a complete empty view controller), but it's always shown black.
I push it using the the navigation [self.navigationController pushViewController] code line.
This is not happening with table controllers, just with view controllers.
Any suggestion?
I'm using Xcode 4.3.2 4E2002.
Thanks in advance,
Samuel
Have you defined your storyboard correctly? This behavior could happen if you failed to properly initialize your storyboard and instantiate your controller from the storyboard. IE, you need to create a UIStoryboard object and need to instantiate your controller by calling
[storyboardObject instantiateViewControllerWithIdentifier: #"controllerName"]; ...See the thread here: http://mobile.tutsplus.com/tutorials/iphone/ios-5-sdk-storyboards

Only direct subviews of the MainWindow view gets orientation set by iOS?

Whenever my app is rotated, only the viewController of which I've added his view as a subview to the mainwindow gets his interfaceOrientation property updated, the rest remains ignorant of the fact the device has been rotated.
Is it my responsibilty to notify other objects of the change, and if so, what's a nice way to do it?
I've looked into setting interfaceOrientation of my children-viewcontrollers but that's readonly.
Thanks in advance,
I found that calling
willRotateToInterfaceOrientation
and/or
didRotateFromInterfaceOrientation
of the view controller you are going to show worked for me. In my case I was using a Navigation Controller so it was easy to keep track of what was going to be shown to the user next. Below is some code from my project.
- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
[viewController willRotateToInterfaceOrientation:
[self interfaceOrientation] duration:0];
}