Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make UITextView multiline

I'm building an iOS application and I have a UITextView which I fill with a text. The text view is not big enough to store all the text so it just put "..." so that I can't see the rest of the text I've put in the view. Is there a way for me to make the UITextView to be multiline so that it can store all the text I've put in it?

Code :

instructionsTextField=[[UITextField alloc] initWithFrame:CGRectZero];
instructionsTextField.frame = CGRectMake(5, 5, self.view.bounds.size.width-10, 90);
instructionsTextField.backgroundColor = [UIColor whiteColor];
instructionsTextField.alpha = 0.5;
instructionsTextField.delegate = self;
instructionsTextField.text = string;
[mapView_ addSubview:instructionsTextField];

Solved My problem was that I've said that instructionsTextField is a UITextView but then I've allocated it as UITextField. Now it works fine.

like image 863
WWJD Avatar asked Apr 03 '14 11:04

WWJD


2 Answers

You are using UITextField here, it cannot be made multilined(unless you add a view in it). please use UITextView instead.

like image 106
Atul Avatar answered Oct 15 '22 22:10

Atul


Write it

     instructionsTextField=[[UITextView alloc] initWithFrame:CGRectZero];
     instructionsTextField.frame = CGRectMake(5, 5, self.view.bounds.size.width-10, 90);
     instructionsTextField.backgroundColor = [UIColor whiteColor];
     instructionsTextField.alpha = 0.5;
     instructionsTextField.delegate = self;
     instructionsTextField.text = string;

     instructionsTextField.scrollEnable=YES;
     instructionsTextField.userInteractionEnabled = YES;
     instructionsTextField.editable=NO;

    [mapView_ addSubview:instructionsTextField];
like image 3
Parvendra Singh Avatar answered Oct 16 '22 00:10

Parvendra Singh