[英]UIImageView error no visisble @interface for 'UIView' declares the selector 'addSubView'
[英]Unrecognised selector with -[UIView addSubView:]
我遇到了另一个与 iOS 相关的问题。 这次与 UIView 上的 addSubView 有关。
我在 NSMutableArray 中存储了一堆 UIViewController 类。 这个想法是,根据用户从 UIPickerView 中选择的内容,它会将选择器视图移开,然后显示与视图 controller 关联的视图。
为此,我有以下代码:
[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 怎么可能是一个无法识别的选择器。 当然它是内置的之一。 有没有人对这里发生的事情有任何想法?
试试addSubview
(小 "v")
选择器区分大小写!
应该:
[self.view addSubview: controller.view];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.