对于我的应用程序,我正在使用带有动态原型单元格的tableView来实现应用程序内设置。在单元格中,我正在显示主标题和副标题。我想要实现的是,当用户单击其中一个单元格(代表特定设置)时,pickerView将从屏幕底部滑动,显示用户可以选择的选项。我见过一些教程,其中的pickerView像这样在单元格中显示在iOS日历应用中,但我不需要–如果它实际上以与将pickerView用作文本字段的inputView时相同的方式从底部滑动,那么一切都会很好(例如,textField.inputView = pickerView)然后单击到文本字段。感谢您能为您提供的任何帮助!提前致谢!

最佳答案

You can create a custom view xib in which you can have pickerView,when user click on cell just show the custom view with animation.

viewPicker = CGRectMake(0, 490, 320, 460);

For the animation from bottom to top add below:

[UIView animateWithDuration:0.5
                      delay:0.1
                    options: UIViewAnimationCurveEaseIn
                 animations:^{
                     viewPicker.frame = CGRectMake(0, 0, 320, 460);
                 }
                 completion:^(BOOL finished){
                 }];
[self.view addSubview:viewPicker];


For removing the view

[UIView animateWithDuration:1.5
                              delay:0.5
                            options: UIViewAnimationCurveEaseIn
                         animations:^{
    viewPicker.frame = CGRectMake(0, 490, 320, 460);
                         }
                         completion:^(BOOL finished){
                             if (finished)
                                 [viewPicker removeFromSuperview];
                         }];

关于ios - 选择单元格时显示UIPickerView,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44218983/

10-12 07:05