-3

私はUIView * myViewを作成し、次にUITextVIew * tempUITextViewを作成し、そのテキストを次のように設定しました

[tempUITextView setText:@"some text"];
[myView addSubView: tempUITextView];

コードを実行すると、エラーが発生します:キャッチされていない例外 'NSInvalidArgumentException' によるアプリの終了、理由: '-[UIView setText:]:

4

3 に答える 3

1

次のことを行います。

UIView *myView = [[UIView alloc]initWithFrame:CGRectMake(0, 280, 320, 180)];//Any frame you want to set
[myView setBackgroundColor:[UIColor redColor]]; // Given color to differntiate between myView and tempUITextView
UITextView *tempUITextView = [[UITextView alloc]initWithFrame:CGRectMake(0, 0, 200, 100)];//Any frame for tempUITextView in myView
[tempUITextView setText:@"hi"];
[myView addSubview:tempUITextView];
[self.view addSubview:myView];
于 2012-05-23T05:29:31.813 に答える
0

あなたの間違いはこの行にあります

UITextView* tempUITextView =[[[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 30)] autorelease];

に置き換えます

UITextView* tempUITextView =[[[UITextView alloc]initWithFrame:CGRectMake(0, 0, 100, 30)]autorelease];
于 2012-05-23T05:47:07.737 に答える
-1

ビューとテキストビューにIBOutletsを使用していますか?その場合は、コンセントを間違ったオブジェクトに接続していないかどうかを確認してください。

于 2012-05-23T05:36:21.020 に答える