I have a UIView which i am presenting to the user which contains a UIPickerView to select between different values. When this view is shown, it is shown asynchronously and my method which opened the UIView has ending before getting any meaningful data from the UIPickerView.
Is there a way to present such controls modally while halting execution of the opening method so that i can test the results after they have been selected?
I’ve tried presenting the UIPickerView inside a UIView and UIAlertView and both are the same, my method returns before i’ve used the controls.
i’ve tried:
[self presentModalViewController:self.Picker animated:YES];
and still no joy.
You definitely don’t want -presentModalViewController:Animated:. That method is intended to present UIViewControllers, and your Picker is a regular ol’ UIView. As for your specific question, the quick answer is “No”.
What you’re going for here requires a slightly different design philosophy. Instead of having one method to both present the picker and get input from it as you desire, you’ll need 2 methods: one to present the picker, probably with UIView’s animation methods, and another to act on input from it.
Specifically, by setting yourself as the delegate of the UIImagePicker, you can present it and be assured that later, at some undefined time in the future, the picker will tell you (via pickerView:didSelectRow:inComponent: delegate method) that it has selected an item. At this time, you can test the selected values and act accordingly. Take a look at the UIPickerViewDelegate Protocol Reference for details on the delegate methods.