سؤال

I'm having another iOS related issue. This time relating to addSubView on a UIView.

I am storing a bunch of UIViewController classes in an NSMutableArray. The idea is that depending on what the user picks from a UIPickerView it will move the picker view out the way and then display the view associated with the view controller.

To this end I have the following code:

[navItem setTitle: [cheatArray objectAtIndex:row]];
UIViewController* controller    = [cheatViewControllers objectAtIndex: row];
if ( controller != nil )
{
    CGPoint animateTo;
    animateTo.x =  thePickerView.bounds.size.width  / 2;
    animateTo.y = -thePickerView.bounds.size.height / 2;
    [UIView animateWithDuration:0.5f delay: 0.0f options:UIViewAnimationOptionAllowUserInteraction animations:^{ [thePickerView setCenter: animateTo]; } completion:nil];

    [self.view addSubView: controller.view];
}

The only problem is that when I call addSubView I get an error:

 -[UIView addSubView:]: unrecognized selector sent to instance 0x581ba00

I'm lost as to how this could happen. How can addSubView possibly be an unrecognised selector. Surely its one of the built in ones. Has anyone got any ideas as to what is going on here?

هل كانت مفيدة؟

المحلول

try addSubview (small "v")
Selectors are case-sensitive!

نصائح أخرى

Should be:

[self.view addSubview: controller.view];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top