72921

Detect backward/pop navigation in destination view controller viewWillAppear [duplicate]

Question:

This question already has an answer here:

<ul><li> <a href="/questions/54207143/detect-when-view-controller-appears-from-pop" dir="ltr" rel="nofollow">Detect when view controller appears from pop</a> <span class="question-originals-answer-count"> 1 answer </span> </li> </ul>

There are a number of well known solutions for detecting when a view controller is in the process of disappearing off the screen in the process of a backwards navigation, managed by a UINavigationController (i.e. when a view controller is being popped off the navigation stack). In other words detecting a backwards navigation within the source view controller.

In contrast, I need to detect a backwards navigation within viewWillAppear for the <em>destination</em> view controller. Or to put it another way, detect when a view controller is about to be displayed as a result of a UINavigationController pop.

What is the cleanest/simplest way to achieve this? Implementing UINavigationControllerDelegate and setting a flag might be one approach, but would rather avoid mutable state if possible.

I am not using Storyboards to manage the transition between these two screens.

Answer1:

Checkout this property of UIViewController :P

<a href="https://developer.apple.com/documentation/uikit/uiviewcontroller/2097561-ismovingtoparentviewcontroller" rel="nofollow">isMovingToParentViewController</a>

<a href="https://developer.apple.com/documentation/uikit/uiviewcontroller/2097565-ismovingfromparentviewcontroller" rel="nofollow">isMovingFromParentViewController</a>

Recommend

  • Android NFC: enable and disable the NFC detected sounds
  • How to install iconv-devel on CentOS 5.6?
  • Invoke method on generic type?
  • Using C++ shared pointer's aliasing constructor with an empty shared pointer
  • Are multiple functions in one .m file nested or local when “end” isn't used
  • websocket._exceptions.WebSocketProxyException: failed CONNECT via proxy status: 503
  • Implementation of RSA without dynamic allocation
  • Segfault reading lazy bytestring past 2^18 bytes
  • Alembic: When autogenerating migrations how to ignore database tables by other products
  • Ajax check if username exists
  • How to make the url from APIGateway to AWS Lambda was available only from a certain domain
  • Gradle task for local tomcat deployment
  • How to capture if current vendor is selected
  • Recursive method - Java
  • Linux file permissions(in-depth) - numeric to string notation, and vice versa; additional file-permi
  • Segmentation fault (core dumped) in Qt5 application
  • Troubleshooting HTTPClient asynchronous POST and reading results
  • inserting ViewController In between the stack of self.navigationController.viewcontroller
  • Youtube Android/IOS SDKs don't seem to count views when playing
  • org.springframework.core.convert.ConverterNotFoundException: No converter found capable of convertin
  • Why $.each() is slower than for loop in jquery?
  • set clipboard content in any browser
  • Firebase Cloud Messaging: how to send data message to all users? [duplicate]
  • In an Outlook addin, how to check whether we are in compose mode or read mode?
  • Eloquent Javascript: Can't understand how the number value is determined in the sum function
  • How to add a progress ring to the splash screen in Windows 8?
  • How can I progmatically click a link in a Winform Web Browser control?
  • CameraPreviewImageSource empty preview frame
  • web2py: How to execute instructions before delete using SQLFORM.smartgrid
  • ClearCase can I use clearexport_ccase/clearimport to copy VOB data to a VOB on a different machine
  • How can I access the Google account user_id?
  • How to set http status code when responding to servlet client from Filter class-method in tomcat
  • Can someone explain how Yii minimizing assets is supposed to work on Heroku?
  • Directed graph linear algorithm
  • Filtering out choiceless polls in the Django tutorial causes polls in the index to duplicate
  • Querying Elasticsearch Address Based Index
  • Circular Left Rotation Algorithm in C#
  • How to change the host IP sent in emails to new GitLab users to a publicly visible IP, not the local
  • How to use Typescript with libraries like Ampersand.js that parse configs to build prototypes
  • Cloud Code: Creating a Parse.File from URL