Question

Je suis en train d'avoir une lame de UIPickerView à partir du bas de l'écran (sur le dessus d'une barre d'onglets) mais ne peut pas sembler obtenir à apparaître. Le code réel pour l'animation vient d'un exemple des projets de code d'Apple (DateCell). J'appelle ce code du premier contrôleur de vue (FirstViewController.m) sous le contrôleur de barre d'onglets.

- (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;
}}

Chaque fois que cette action est déclenchée par un UIBarButtonItem qui vit dans un UINavigationBar (ce qui est tout sous le FirstViewController) rien ne se passe. Quelqu'un peut-il s'il vous plaît donner quelques conseils?

Était-ce utile?

La solution

avère que j'avais manqué le fait très important que le UIPickerView avait été défini dans Interface Builder et ... après avoir fait cela et relier le tout de sortie fonctionne!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top