Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Have you tried just hard coding the frame logic? This could be very effective. All you have to do is conditionally populate an array containing pointers to your text fields and then perform a little frame arithmetic on their y origins. For example, this could easily display all the fields:</p> <pre><code>NSArray *fields = @[topTextField, middleTextField, bottomTextField]; for (int i = 0 ; i &lt; fields.count ; i ++) { UITextField *field = fields[i]; [field setFrame:CGRectMake(20.0, 20.0 + (i * 50.0), 280.0, 34.0)]; } </code></pre> <p>Produces this:</p> <p><img src="https://i.stack.imgur.com/puy0W.png" alt="enter image description here"></p> <p>Or at its most basic level, something like this could be used to check whether any of the text fields should/shouldn't be shown, and either hides them, or adjusts their frame accordingly.</p> <pre><code>BOOL shouldShowTop = YES; BOOL shouldShowMiddle = NO; BOOL shouldShowBottom = YES; NSMutableArray *fields = [NSMutableArray new]; if (shouldShowTop) { [fields addObject:topTextField]; }else{ [topTextField setHidden:YES]; } if (shouldShowMiddle) { [fields addObject:middleTextField]; }else{ [middleTextField setHidden:YES]; } if (shouldShowBottom) { [fields addObject:bottomTextField]; }else{ [bottomTextField setHidden:YES]; } for (int i = 0 ; i &lt; fields.count ; i ++) { UITextField *field = fields[i]; [field setFrame:CGRectMake(20.0, 20.0 + (i * 50.0), 280.0, 34.0)]; } </code></pre> <p>Will produce this:</p> <p><img src="https://i.stack.imgur.com/93rrX.png" alt="enter image description here"></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.
    1. This table or related slice is empty.
    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