Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There's a lack of details here. How are you "exchanging" the two views?</p> <p>If you were using a UINavigationController as the container then viewWillAppear/viewDidAppear would be called whenever you push/pop a new viewController. These calls are made by the UINavigationController itself. If you ARE using a UINavigationController then make sure you have the prototypes correct for these functions.</p> <pre><code>- (void)viewWillAppear:(BOOL)animated </code></pre> <p>If you are trying to implement a view hierarchy yourself then you may need to make these calls yourself as part of activating/deactivating the views. From the SDK page of viewWillAppear;</p> <blockquote> <p>If the view belonging to a view controller is added to a view hierarchy directly, the view controller will not receive this message. If you insert or add a view to the view hierarchy, and it has a view controller, you should send the associated view controller this message directly.</p> </blockquote> <p><strong>Update:</strong></p> <p>With the new details the problem is clear: This is a situation where you must send the disappear/appear messages yourself as suggested by the SDK. These functions are not called automagically when views are directly inserted/removed/changed, they are used by higher-level code (such as UINavigationController) that provides hierarchy support.</p> <p>If you think about your example of using exchangeSubView then nothing is disappearing, one view just happens to cover the other wholly or partially depending on their regions and opacity.</p> <p>I would suggest that if you wish to swap views then you really do remove/add as needed, and manually send the viewWillAppear / viewWillDisappear notifications to their controllers.</p> <p>E.g.</p> <pre><code>// your top level view controller -(void) switchActiveView:(UIViewController*)controller animated:(BOOL)animated { UIController* removedController = nil; // tell the current controller it'll disappear and remove it if (currentController) { [currentController viewWillDisapear:animated]; [currentController.view removeFromSuperView]; removedController = currentController; } // tell the new controller it'll appear and add its view if (controller) { [controller viewWillAppear:animated]; [self.view addSubView:controller.view]; currentController = [controller retain]; } // now tell them they did disappear/appear [removedController viewDidDisappear: animated]; [currentController viewDidAppear: animated]; [removedController release]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload