Showing a Uipickerview with Uiactionsheet in iOS8 Not Working

Showing a UIPickerView with UIActionSheet in iOS8 not working

From the reference for UIActionSheet:

UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with presentViewController:animated:completion:.

My guess is your seeing exactly why.

The reference for UIAlertController doesn't have a similar disclaimer, but looking at its interface, my guess is Apple will add it before release.

My recommendation would be to just create a small view containing your picker and buttons and show and hide it as needed. It's not that hard to do and your not pushing interfaces beyond their intended uses.

UIPickerView with UIActionSheet IOS 8 stop working

The link provided above actually refers to Apple Doc where it has removed adding subview to UIActionSheet. In your code, you are doing similar thing by adding UIPickerView into UIActionSheet. So in iOS8 onwards, even if the view is added to UIActionSheet, the view returned is actually nil while displaying.

For this purpose you can use ActionSheetPicker-3.0.
Actually, it's not UIActionSheet anymore. But looks exactly the same, and that's why it works on iOS8.
Do let me know if this answers your query!

how to manage uipickerview in uiactionsheet

Finally i got the solution

First of all i have to set the width of the picker view as i have mentioned

CGRect pickerFrame=CGRectMake(0, 40, 0, 0);

so it can be like

CGRect pickerFrame=CGRectMake(0, 40, 320, 0);

I found one more good solution :

Just call the picker view in action sheet by clicking a text field:

self.textField.inputView = yourCustomView;

UIActionSheet not showing in iOS 8

UIActionSheet is deprecated in iOS 8.

Sample Image

To create and manage action sheets in iOS 8 you should use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet.

Refer this example.

iOS UIDatePicker not showing inside a UIActionSheet

According to Apple docs

Important: UIActionSheet is deprecated in iOS 8. (Note that UIActionSheetDelegate is also deprecated.) To create and manage action sheets in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet.

or you can add datePicker as an inputView to the Textfield. (Just use UITextfield instead of UIButton to open the picker)

UIDatePicker *datepicker = [[UIDatePicker alloc] initWithFrame:CGRectZero];
[datepicker setDatePickerMode:UIDatePickerModeDate];
myTextField.inputView = datepicker;

UIPickerView Not Working In IOS 8

I solve this by making programmatically picker-view , problem is in my view because i create two view one is main and second is sliderview , calling picker from view for slider view ,
now my code is look like this

 - (void)viewDidLoad
{
UIPickerView *myPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
myPickerView.delegate = self;
myPickerView.showsSelectionIndicator = YES;
//[sliderView addSubview:_myPickerView];

txtstreet.inputView=_myPickerView;
myArray = arrwithdata;
}

and other code is same ... it's work in both os.



Related Topics



Leave a reply



Submit