3

This is similar behaviour to a previous bug report: Rotating within a question in the iOS app messes up the question list

Steps to reproduce:

  1. Start on a list of questions.
  2. Tap to enter the inbox.
  3. Rotate your device to trigger a screen rotation, then rotate again to trigger a rotation to the original orientation.
  4. Tap to dismiss the inbox.

The spacing of the questions is totally messed up by this sequence of actions.

Here’s a before-and-after shot starting in portrait:

enter image description here

and in landscape:

enter image description here

The same behaviour can be reproduced if you replace “inbox” with “achievements”, and if you drill down into a question from one of those screens. (For example, get a comment in your inbox, tap through to the question, then use the back chevrons to return to the question list, having rotated while looking at the question.)

I can reliably reproduce in App Store build v1.3.0, iOS 8.3 (12F70) on an iPhone 5s.

4

Nice catch. This will be fixed in the next build. (Not 1.3.1 but 1.3.2 or 1.4.0.)

I'm not exactly sure what's triggering the problem, but here's the gist of it. Generally when you rotate the device there's a chain of notifications that includes:

  1. The individual questions get a new width and update their layout.
  2. This triggers the questions title's width to change.
  3. We notice the width changes and say "Start wrapping the title with the new width rather than the old width"
  4. Because of that, the layout gets updated again using the height it gets from wrapping the text.
  5. The cell and title are then drawn using that new width.

What appears to be happening is that when you first rotate the steps run normally but when you rotate again step 3 (and as a result 4) are skipped. The cell height is also independently calculated at what should be the correct value.

As a result, the cell height and rendered title are based on the title having the correct width and the vertical space for the title and the tag location are based on the title having an incorrect width.

Looking at your second screenshot "Why does Captain America need to exercise?" would fit on one line in landscape so only the title is only given one line. Similarly in the fourth screenshot, "How do people carry things in Star Trek TNG?" required two lines in portrait so it's given enough height for two lines (and ends up vertically centering in that space).

The solution I've come up with is to explicitly notify the layout system that the title wrapping width changed.

- (void)setFrame:(CGRect)frame
{
    [super setFrame:frame];
    CGFloat newWidth = CGRectGetWidth(frame);
    if (newWidth != self.preferredMaxLayoutWidth) {
        self.preferredMaxLayoutWidth = newWidth;
        [self invalidateIntrinsicContentSize]; // Added line.
    }
}
  • Thanks for the detailed explanation. I’ll mark this as accepted when it shows up in shipping build. – alexwlchan Apr 21 '15 at 22:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .