Showing a UIPickerView with UIActionSheet in iOS8

2019-01-13 20:32发布

Showing a UIPickerView with UIActionSheet in iOS8 not working

The code works in iOS7, however it is not working in iOS8. I'm sure it is because UIActionSheet is deprecated in iOS8 and Apple recommends to use UIAlertController.

However, how to do it in iOS8? I should use UIAlertController?

iOS7:
enter image description here

iOS8:
enter image description here

EDIT:

My GitHub project solving the problem.

8条回答
Luminary・发光体
2楼-- · 2019-01-13 21:05

To achieve the same visual effect you can use ActionSheetPicker-3.0, that works with iOS 8.

Actually, it's not UIActionSheet anymore. But looks exactly the same, and that's why it works on iOS 8.

animation

查看更多
Ridiculous、
3楼-- · 2019-01-13 21:07

Look at my code

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
                                                                       message:@"\n\n\n\n\n\n\n\n\n\n\n"             preferredStyle:UIAlertControllerStyleActionSheet];

__weak typeof(self) weakSelf = self;
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确认"style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
            [weakSelf pickActionSheetFinishAction];



[alertController addAction:cancelAction];
[alertController.view addSubview:self.topicPickView];
[self presentViewController:alertController animated:YES completion:nil];
查看更多
登录 后发表回答