I am very very new to iOS programming / Objective C.
The flow of events I want to have happen is: user selects tab from tab bar view controller. Once VIEW A has been loaded it will open a modal window to get some information
ModalYearPickerViewController *modalYearPickerViewController= [[ModalYearPickerViewController alloc] init];
[self presentViewController:modalYearPickerViewController animated:NO completion:nil];
I am trying to have my year picker view load up right away so the user can select a year from my picker (in VIEW B), then close the modal window after the value has been passed back to VIEW A.
Now, the fist view loads, then goes to a black screen automatically. I am unsure why as my view controller for modalYearPickerViewController has a picker etc on it.
Any tips or help loading a modal view controller programmatically would be greatly appreciated!
Thanks!
If you are using storyboards :
UIStoryboard *storyBoard = [self storyboard];
This will return the storyboard of your current view controller. I am assuming your View Controller A is also on your storyboard.
ModalYearPickerViewController *modalYearPickerViewController = [storyBoard instantiateViewControllerWithIdentifier:@"ModalYearPickerViewController"];
This will instantiate your view controller from the storyboard. But one other thing you have to do is set your view controllers storyboard id to ModalYearPickerViewController
. You can set this right below where you set your custom view controller class in the storyboard.
[self presentViewController:modalYearPickerViewController animated:NO completion:nil];
and done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With