-1

uitextviewユーザーが同じをクリックするたびに新しいを作成したいと思いますuibutton

いくつかのコードを書き込もうとしましたが、作成できるのは 1 つuitextviewだけです。私を助けるために提供できるサンプルコードがあればうれしいです。

前もって感謝します。

    UITextView *newTextView =[[UITextView alloc]init];
    newTextView.frame=CGRectMake(0,0,100,100);
    [textView addSubview:newTextView];
    newTextView.delegate=self;
    [newTextView release];
4

2 に答える 2

1

コードの場合、textView必要に応じて新しいものを作成しますが、最後のものと重複するため、その新しいものを見ることができます。作成する必要があるたびint y variableに値を増やしてから、のを変更しy codinateますtextView

-(IBAction)addTView:(id)sender  {
    UITextView *newTextView =[[UITextView alloc]init];
    newTextView.frame=CGRectMake(0,y,100,100);
    [textView addSubview:newTextView];
    newTextView.delegate=self;
    [newTextView release];
    y = y + 100; 
}

次に、使用して追加したいビューに追加します[self.view addSubView: yourView]

于 2013-05-15T08:27:14.223 に答える
0
-(IBAction)textviewadd:(id)sender  {
UITextView *View =[[UITextView alloc]init];
newTextView.frame=CGRectMake(0,y,100,100);
[self.view addSubview:txtView];
txtView.delegate=self;
[txtView release];
y = y + 150; 
}

このコードがお役に立てば幸いです。

于 2013-05-18T07:41:40.903 に答える