0

別の iOS 関連の問題が発生しています。今回は UIView の addSubView に関するものです。

NSMutableArray に一連の UIViewController クラスを格納しています。アイデアは、ユーザーが 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 が認識されないセレクターになる可能性があります。確かに、組み込みのものの1つです。ここで何が起こっているのか、誰かが何か考えを持っていますか?

4

2 に答える 2

8

try addSubview(小文字の "v")
セレクターは大文字と小文字を区別します!

于 2011-06-10T11:10:24.390 に答える
4

次のようにする必要があります。

[self.view addSubview: controller.view];
于 2011-06-10T11:11:22.857 に答える