Question

I'm having a bit of trouble wrapping my head around the way a container view controller is meant to be implemented.

I dragged a container into my main view controller and it automatically creates the embedded view controller and is connected via an embed segue. I can then access it from my main view controller via prepareForSegue.

I'm a bit confused as to creating and using these on the fly. Ie say I want to use it as an alert view. Am I meant to just initialize the view once, and then change its contents each time the display is meant to be triggered? Should I be calling presentViewController or just setting hidden/animating the view in and out?

Having trouble articulating. Hopefully someone speaks newb and can understand me.

Was it helpful?

Solution

Using an embedded controller that you get with a container view is not a good fit for something like an alert. You can't create these "on the fly" this way, since that embedded controller is instantiated at the same time as the controller it's contained in (you don't president it). You can do the same thing in code as what a container view gives you using the custom container controller procedures (see Apple's "Creating Custom Container View Controllers" document). If you just want to make a custom alert view like view, I would just create a custom view and add it as a subview to your controller.

OTHER TIPS

Use setHidden: method when you want to show or hide that view.

[_myAlertView setHidden:YES];

[_myAlertView setHidden:NO];

I hope that I understood your question correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top