无法识别的选择器 -[UIView addSubView:]
我遇到了另一个与 iOS 相关的问题。这次涉及 UIView 上的 addSubView。
我将一堆 UIViewController 类存储在 NSMutableArray 中。这个想法是,根据用户从 UIPickerView 中选择的内容,它将把选择器视图移开,然后显示与视图控制器关联的视图。
为此,我有以下代码:
[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];
}
唯一的问题是,当我调用 addSubView 时,我收到错误:
-[UIView addSubView:]: unrecognized selector sent to instance 0x581ba00
我不知道这是如何发生的。 addSubView 怎么可能是一个无法识别的选择器。当然它是内置的之一。有人对这里发生的事情有任何想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
addSubview
(小“v”)选择器区分大小写!
try
addSubview
(small "v")Selectors are case-sensitive!
应该是:
Should be: