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

标签 iphone objective-c ios uiview addsubview

我遇到了另一个与 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/

相关文章:

iphone - 应用程序中有 UITabBar 和 UINavigationController 吗?

iphone - UITextView 委托(delegate)方法未触发

iphone - 如何维护 TableView 中行的选择状态?

ios - 如何在 NSObject Swift 3.0 的 NSArray 中搜索字符串?

ios - Callkit 中的群组通话

html - 后台附件:已修复在 iOS 上不起作用

iphone - 不将数据放入我的核心数据数据库中

ios - UIDatePickers 高度没有动画?

iOS Google Places API : "This IP, site or mobile application is not authorized to use this API key"

ios - 当我尝试从 Firebase 检索数据库信息时,为什么 SwiftUI 会显示错误?