Note that there are some explanatory texts on larger screens.

plurals
  1. POUITextView, setContentOffset and missing bottom part
    primarykey
    data
    text
    <p>For some strange reason, my UITextView's text appears cropped when the scrollofset is set.</p> <p>Here's what it looks like: <img src="https://i.stack.imgur.com/1o2IO.png" alt="enter image description here"></p> <p>This happens after doing:</p> <pre><code> textview.contentInset = UIEdgeInsetsZero; [textview setContentOffset:CGPointMake(0, startypos + offset_yshift) animated:NO]; </code></pre> <p>I tried manually setting contentSize.height, but that introduced another strange behavior, where the content offset seems to be ignored..</p> <p>''Edit'': This is the code used to instantiate the textfield:</p> <pre><code> CGRect myImageRect = CGRectMake(-50.0f, -50.0f, 40.0f, 40.0f); textview = [[UITextView alloc] initWithFrame: myImageRect]; textview.autocapitalizationType = UITextAutocapitalizationTypeNone; [textview setScrollEnabled:YES]; textview.hidden = YES; textview.contentInset = UIEdgeInsetsZero; textview.opaque = NO; textview.backgroundColor = [UIColor clearColor]; textview.textColor = [UIColor colorWithWhite:1 alpha:1]; textview.textAlignment = NSTextAlignmentCenter; textview.frame = CGRectMake(0, 0, 250, 30); textview.scrollEnabled = NO; </code></pre> <p>And the "update" code that checks the content positioning every frame:</p> <pre><code> // setting the actual size here UITextPosition * pos = [textview positionFromPosition: textview.endOfDocument offset:nil]; CGRect therect = [textview caretRectForPosition:pos]; CGRect frame = textview.frame; if([textview.text length] == 0){ frame.size.height = 30; } else { frame.size.height = therect.origin.y + therect.size.height; } // and here, we're changing the frame variable's height to max to 50 if(frame.size.height &gt; 50){ frame.size.height = 50; } frame.size.width = desiredwidth; // some other variable textview.frame = frame; /* ... snip, unrelated code ... */ // later on textview.contentInset = UIEdgeInsetsZero; [textview setContentOffset:CGPointMake(0, startypos + offset_yshift) animated:NO]; </code></pre> <p>As you can imagine, the setContentOffset bit there is what's causing the issue.</p> <p>What is going on?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload