3

I am newbie for iPhone application. I want to add TextArea. I know how to add textField, however can someone help me how can I have Textare in my iPhone application?

I thought, I can increase the height of textfield and make it multi-line, however that option is not there.

Shmidt
  • 16,436
  • 18
  • 88
  • 136
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
  • 2
    Why can't you look through all standard components in IB? UITextView is not something hard to find. – Shmidt Jan 06 '13 at 21:28
  • 1
    @Flink : I have used `UITextView` many time, but I was under impression that `UITextView` is only for displaying text. `Editable` option did the trick. – Fahim Parkar Jan 07 '13 at 06:25

3 Answers3

8

You cannot increase the height of UITextField. for this you need to use UITextView. In your Interface builder where you got UITextField, there is also an option of UITextView. you can use UITextView same as UITextField in iPhone. UITextView is used for multiple lines

UITextView  *txt = [[UITextView  alloc]init];

//set frame

//add on view

[self.view addSubView:txt];

[txt release];

I hope this solves your problem Sample Code for TextView

docksteaderluke
  • 2,195
  • 5
  • 27
  • 38
Satish Azad
  • 2,302
  • 1
  • 16
  • 35
3
UITextView  *txt = [[UITextView  alloc]initwithframe:CGRectMake(x, y, width,height)];



[self.view addSubView:txt];

[txt release];
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
anand madhav
  • 353
  • 4
  • 10
  • Please add some form of description as to how the code you posted addresses the problem. Also, you should place any code in your answers within code blocks. – Ren May 07 '13 at 11:07
0

You could simply do this by clicking on Mainstoryboard.storyboard or viewController.xib and dragging in a UITextView This will allow multi-line text. If you need to access the Textview, type:

.h file

{
  IBOutlet UIITextView *textView;
}

 @property (nonatomic, strong) IBOutlet UITextView* textView;

.m file
@synthesize textView;

EDIT

to get the users data, hook up the outlet in storyboards,

then use:

-(void)getUserText{
NSLog@"%@", self.textView);


}

This should print out whatever the user entered into the textView.

Bad_APPZ
  • 432
  • 1
  • 3
  • 12