2011-12-07 8 views

答えて

3

UITextViewのテキストを変更するには、そのtextプロパティ設定

UIButton *yourButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
[yourButton setTitle:@"click to change textview's text" forState:UIControlStateNormal]; 
[yourButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; 

... 

- (void)buttonClicked:(id)sender { 

    textView.text = @"your text"; 
} 
+0

はあなたに感謝を!!!! !! – Jeeter

+0

フォントとプロパティを変更せずにテキストを変更するにはどうすればよいですか? –

+0

@AlbertCatalà:あなたはおそらくこのバグを実行しています:http://stackoverflow.com/questions/19049917/uitextview-font-is-being-reset-after-settext –

0

UITextViewの値を変更するメソッドを作成するだけです。それをIBの正しい方法でtextViewに接続すれば完了です。

textView.text = @"your text here";

あなたがそうのようにボタンのセレクタの中からこれを呼び出すことができます:

関連する問題