简体   繁体   English

无法识别的选择器 -[UIView addSubView:]

[英]Unrecognised selector with -[UIView addSubView:]

I'm having another iOS related issue.我遇到了另一个与 iOS 相关的问题。 This time relating to addSubView on a UIView.这次与 UIView 上的 addSubView 有关。

I am storing a bunch of UIViewController classes in an NSMutableArray.我在 NSMutableArray 中存储了一堆 UIViewController 类。 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.这个想法是,根据用户从 UIPickerView 中选择的内容,它会将选择器视图移开,然后显示与视图 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:唯一的问题是,当我调用 addSubView 时出现错误:

 -[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. addSubView 怎么可能是一个无法识别的选择器。 Surely its one of the built in ones.当然它是内置的之一。 Has anyone got any ideas as to what is going on here?有没有人对这里发生的事情有任何想法?

try addSubview (small "v")试试addSubview (小 "v")
Selectors are case-sensitive!选择器区分大小写!

Should be:应该:

[self.view addSubview: controller.view];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM