Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Container Controller Lifecycle #211

Closed
1 task done
k0nserv opened this issue Nov 20, 2019 · 3 comments
Closed
1 task done

Incorrect Container Controller Lifecycle #211

k0nserv opened this issue Nov 20, 2019 · 3 comments

Comments

@k0nserv
Copy link

k0nserv commented Nov 20, 2019

Report

Describe your environment.

Info Value
Platform Name ios
Platform Version All
SDK Version 3.20.2
Integration Method cocoapods
Xcode Version Xcode 11.2
Repro rate all the time (100%)

What did you do?

Implemented a custom view controller for IAM display

What did you expect to happen?

For the view of my controller to have its layout specified by the parent view controller and for the parent view controller to correctly handle the container view controller lifecycle.

What happened instead?

The view of my custom view controller was not laid out by its parent view controller and the parent view controller did not correctly perform container view controller lifecycle.

Steps to reproduce

Create a project with custom view controller for IAM observe that view.superview is not set until viewDidAppear and there is no layout specified for view.

@k0nserv
Copy link
Author

k0nserv commented Nov 20, 2019

As explained in Apple's Documentation on container view controllers the order of actions that parent view controllers should take when adding a child view controller are:

  1. Call the addChildViewController: method of your container view controller.
  2. Add the child’s root view to your container’s view hierarchy.
  3. Add any constraints for managing the size and position of the child’s root view.
  4. Call the didMoveToParentViewController: method of the child view controller.

What Braze does is the following:

  1. Call the addChildViewController: method of your container view controller.
  2. Call the didMoveToParentViewController: method of the child view controller.
  3. Add the child’s root view to your container’s view hierarchy.
  4. Add any constraints for managing the size and position of the child’s root view.

This means that in didMoveToParentViewController: view.superview is still nil. Further it would be more reasonable if the parent view controller(ABKInAppMessageWindowController) was responsbile for laying out the message view controller's root view as recommended by Appple.

The default Braze implementations of IAM workaround this by doing layout much later in the lifecycle(viewWillAppear:).

@hokstuff
Copy link
Collaborator

hokstuff commented Mar 9, 2020

Hi @k0nserv,

Thank you for reaching out and filing this issue with these technical details. We are now tracking this ticket internally.

Best,
Daniel

@hokstuff
Copy link
Collaborator

Hi @k0nserv,

Thanks for filing this issue about our SDK. I'm updating here because we are planning to address this more holistically in our upcoming Swift SDK. Please reference this thread to sign up for our early access program and stay tuned for additional updates regarding the new SDK!

Since there are no immediate follow ups for this issue, I am closing it out. Thank you for understanding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants