Вопрос

Я пытаюсь отобразить слайд UIPickerView в нижней части экрана (поверх панели вкладок), но, похоже, он не отображается.Фактический код для анимации взят из одного из проектов Apple example code (DateCell).Я вызываю этот код из первого контроллера просмотра (FirstViewController.m) под контроллером панели вкладок.

- (IBAction)showModePicker:(id)sender {
if (self.modePicker.superview == nil) {
    [self.view.window addSubview:self.modePicker];

    // size up the picker view to our screen and compute the start/end frame origin for our slide up animation
    //
    // compute the start frame
    CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
    CGSize pickerSize = [self.modePicker sizeThatFits:CGSizeZero];
    CGRect startRect = CGRectMake(0.0, screenRect.origin.y + screenRect.size.height, pickerSize.width, pickerSize.height);
    self.modePicker.frame = startRect;

    // compute the end frame
    CGRect pickerRect = CGRectMake(0.0, screenRect.origin.y + screenRect.size.height - pickerSize.height, pickerSize.width, pickerSize.height);

    // start the slide up animation
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];

    // we need to perform some post operations after the animation is complete
    [UIView setAnimationDelegate:self];

    self.modePicker.frame = pickerRect;

    // shrink the vertical size to make room for the picker
    CGRect newFrame = self.view.frame;
    newFrame.size.height -= self.modePicker.frame.size.height;
    self.view.frame = newFrame;
    [UIView commitAnimations];

    // add the "Done" button to the nav bar
    self.navigationItem.rightBarButtonItem = self.doneButton;
}}

Всякий раз, когда это действие запускается через UIBarButtonItem, который находится в UINavigationBar (который находится под FirstViewController), ничего не происходит.Кто-нибудь, пожалуйста, может дать какой-нибудь совет?

Это было полезно?

Решение

Оказывается, я упустил очень важный факт, что UIPickerView также был определен в Interface Builder...после этого и подключения розетки все заработало!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top