Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text scrolls outside of the UITextView box boundary

I have a UITextView that has some text in it. The problem is that the text scrolls outside of the boundaries of the UITextView box. (The UITextView is uneditable.)

here's the code and what I have tried to resolve this issue:

  - (void)viewDidLoad {

        textBG.contentInset = UIEdgeInsetsZero;

    //  textBG.layer.masksToBounds = NO;
        textBG.layer.cornerRadius = 10.0;
        textBG.layer.borderWidth = 0.0;
        [textBG setClipsToBounds:YES];

    [super viewDidLoad];
}

- (void)textViewDidBeginEditing:(UITextView*)textView
{

textBG.contentInset = UIEdgeInsetsZero;    
 [textBG setClipsToBounds:YES];   
}

- (void) shouldChangeTextInRange:(UITextView*)textView {

    textBG.contentInset = UIEdgeInsetsZero;    
    [textBG setClipsToBounds:YES];

}

thanks for any help

enter image description here

like image 646
hanumanDev Avatar asked Sep 30 '11 08:09

hanumanDev


2 Answers

write this in textView delegate methods like textViewDidBeginEditing

textBG.contentInset = UIEdgeInsetsZero;

in viewDidload

[textBG setClipsToBounds:YES];
like image 124
Narayana Avatar answered Oct 16 '22 16:10

Narayana


Try to change in XIB for your TextView like below:enter image description here

like image 2
Loquatious Avatar answered Oct 16 '22 17:10

Loquatious