我遇到了另一个与 iOS 相关的问题。这次与 UIView 上的 addSubView 有关。
我在 NSMutableArray 中存储了一堆 UIViewController 类。这个想法是,根据用户从 UIPickerView 中选择的内容,它将选择器 View 移开,然后显示与 View Controller 关联的 View 。
为此我有如下代码:
[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”)
选择器区分大小写!
关于iphone - 无法识别的选择器 -[UIView addSubView :],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6305458/