iPad viewWillAppear and presentModalViewController problems - iphone

In the iPhone, I have a tableview, and touching the cells, I have one method calling presentModalViewController, and opening another view, with email and this kind of stuff.
When the user press the cancel button, the viewWillAppear method in the previous view is called.
So far, so good. But in the iPad, the viewWillAppear is only called the first time that the view appears, anyone knows if this is a bug or it's right?
I tried to implement the
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
with no success.
Does anybody know how to fix this without doing any delegate method from scratch?
Thanks in advance

Since view controllers presented modally don't necessarily completely cover up the underlying view on iPad, the viewWillAppear method does not fire when said modal view controllers get dismissed. I rely on delegate methods to announce to the original view controller the actions of the modal view controller. I think it's the best way to go.

Based on guesswork, rather than reading, testing or anything useful really, but therefore not covered under the NDA...
Is viewWillDisappear being called when you presentModalViewController ? It may be that it doesn't think the modal view obscures the original view fully, therefore (unlike the iPhone) both exist at once ?

Chances are it's a bug, I would file a bug report with apple here.

Related

iOS7 UITabBarController not responding after programmatically changing selectedViewController or selectedIndex

As stated above I'm having problems regarding UITabBarController or specifically the tab bar not responding after manually/programmatically setting the selectedViewController or selectedIndex. This also happens when I pop the view controller of the previously selected tab before moving to another tab screen. Yes I believe I have checked the multiple times the delegate for UITabBarController and yes I have confirmed that the
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
is not being fired. Is there anyone who has experienced this?
Make sure set the delegate right, if not, the delegate method won't be fired.
Seems like loading behavior of assets might have changed in iOS7
Make sure that the view is completely loaded.
Prior to iOS7, you would create the tabbed view, push it, then select the tab.
in ios7, the view is not loaded synchronously. So while you did create it and display it, the select index gets called before it is actually shown and therefore has no effect.
At least this is what bit me as we have started to transition to iOS7

How to check why viewWillDisappear: is called

I need to check if viewWillDisappear: is called because I am presenting another UIViewController as modal or not. Does anyone know if this is possible?
UPDATE
I want to know why it is being called. For example, if its being popped or if another viewcontroller is shown as modal. I need to differentiate the both.
This is only a partial answer to your question, but have a look at "Determining Why a View’s Appearance Changed" in the "View Controller Programming Guide for iOS".
For example, you can call [self isBeingDismissed] from within viewWillDisappear to determine if the view controller was just dismissed (e.g. popped from the navigation stack).
You can set a breakpoint in that method or do NSlog(#"ViewwillDisapper"); So, you can verify whether that method is calling or not.

Is it possible to call a UIEvent between viewWillAppear and viewDidAppear?

Is it possible to handle UIEvents between viewWillAppear and viewWillDisappear?
For example:
Let's say I have a view controller with a UITableView.
When pressing a cell I push a another view controller to the navigation controller (And display it of course).
Is it possible that after the viewWillAppear event of the pushed view (And before the viewDidAppear) I can still press one of the cells in the UITableView?
I am asking this because I am seeing this in the logs of my application and I Never thought that such a thing could be possible..
What do you guys(Or girls) think?
Thanks!
I have one idea may this work,
you use performSelector in viewWillAppear with 0.01 or another time with Delay Parameter and call your method here,
hope,this help you.
:)

viewWillAppear not getting called for detailView of UISplitViewController

I am experimenting with the splitViewController, introduced for iPads and am stuck at a point. I have a button on my detail view of the splitViewController, clicking on which a modal view opens. Now I want to change the positoning of UI controls on the detail view when the modal view gets dissmissed.
A pretty obvious way of doing this would be to catch the view transition in the ViewWillAppear method of the detailView. But it's not being called in this case. I remember facing the same problem in tabBarController where [tabBarController viewWillAppear:animated] was needed to be set before viewWillAppear of views in each tab item got called. I tried doing this with the splitViewController as well, but this doesn't seem to to work.
Any Ideas??
If the positioning is required due to an action that occurred in the modal view, you should use an explicit delegate callback. That will allow you to clearly specify the control flow and resulting behaviour of your app.
You should then define a protocol that has specific methods that carry pertinent information about the action taken. When the action occurs in the modal, perform the protocol method on the delegate, and it can react to that event (for you it seems to be a re-layout of button positioning).
To get an idea of the methods that are abstract enough to handle generic modal behaviour, look at UIAlertViewDelegate protocol. Here the delegate will get an alertViewCancel: message when the user decides to take no action, or alertView:didDismissWithButtonIndex: when they selected one of the options presented to them.
That is a good start for how to define the protocol.
If you need a many view controllers to react to the action taken in the modal, say a Sign In modal, then a better mechanism is notifications.

iPhone viewDidAppear stops firing after loading/dismissing a modal view

I'm starting to go a little crazy with this one.
I have an iphone application with a somewhat complex view structure it is a tabbed application with either a view controller or a navigation controller on each tab.
The main controller for one tab uses the viewDidAppear callback to reload any data that has been modified since the last time it was displayed and this behaves fine in most cases. The issue I have run into is that when I navigate in subviews(within the same tab) using the standard navigation controller push/pop mechanism the viewWillAppear and viewDidAppear on the main view always fire when I navigate back to it.
However if I load a modal view controller and then dismiss it, the viewWillAppear continues to fire but the viewDidAppear stops firing.
I am almost certain that this is tied to the need to manually call these callbacks on the modal controller but I cannot find the reference info on how to do this correctly. (I only see this viewDidAppear bug on the hardware, in the simulator it works as I'd expect)
If you need further clarification let me know and thanks for any input.
Yes, this is how it works. You are better off switching to using viewWillAppear.
This has the added advantage of updating the data before the screen is redrawn.
viewDidLoad should be used for one-time setup operations:
Setting titles
Instantiating subviews, content arrays
Anything else related to the infrastructure of the view in question
After that, use viewWillAppear: to do anything related to refreshing data. You shouldn't have to call any of the viewDid/viewWill methods manually – that's handled by the innards of UIView. viewDidLoad won't fire after you dismiss a modal view controller because, more than likely, the view never unloaded. viewDidLoad fires fine when you're navigating the a view controller stack since the new views need memory, requiring other views to unload, then be reloaded when they reappear.