UIView не изменяет размер при повороте с помощью CGAffineTransform под iOS8

У меня есть UIViewController, который вращает только некоторые из его подпредставлений, когда устройство поворачивается. Это прекрасно работает под iOS7, но ломается под iOS8. Похоже, что границы UIView корректируются с помощью преобразования под iOS8. Это было неожиданно.

Вот некоторый код:

@interface VVViewController ()
@property (weak, nonatomic) IBOutlet UIView *pinnedControls;
@property (nonatomic, strong) NSMutableArray *pinnedViews;

@end

@implementation VVViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.pinnedViews = [NSMutableArray array];
    [self.pinnedViews addObject:self.pinnedControls];
}

-(void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];

    [UIViewController rotatePinnedViews:self.pinnedViews forOrientation:self.interfaceOrientation];
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];

    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation) && UIInterfaceOrientationIsLandscape(self.interfaceOrientation))  {
        [UIViewController rotatePinnedViews:self.pinnedViews forOrientation:toInterfaceOrientation];
    }
}

@end

Мы создали категорию на UIViewController для обработки этого поведения. Вот соответствующий код:

@implementation UIViewController (VVSupport)

+ (void)rotatePinnedViews:(NSArray *)views forOrientation:(UIInterfaceOrientation)orientation {
    const CGAffineTransform t1 = [UIViewController pinnedViewTansformForOrientation:orientation counter:YES];
    const CGAffineTransform t2 = [UIViewController pinnedViewTansformForOrientation:orientation counter:NO];
    [views enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) {
        // Rotate the view controller
        view.transform = t1;
        [view.subviews enumerateObjectsUsingBlock:^(UIView *counterView, NSUInteger idx, BOOL *stop) {
            // Counter-rotate the controlsUIin the view controller
            counterView.transform = t2;
        }];
    }];
}

+ (CGAffineTransform)pinnedViewTansformForOrientation:(UIInterfaceOrientation)orientation counter:(BOOL)counter {
    CGAffineTransform t;
    switch ( orientation ) {
        case UIInterfaceOrientationPortrait:
        case UIInterfaceOrientationPortraitUpsideDown:
            t = CGAffineTransformIdentity;
            break;

        case UIInterfaceOrientationLandscapeLeft:
            t = CGAffineTransformMakeRotation(counter ? M_PI_2 : -M_PI_2);
            break;

        case UIInterfaceOrientationLandscapeRight:
            t = CGAffineTransformMakeRotation(counter ? -M_PI_2 : M_PI_2);
            break;
    }

    return t;
}

@end

Вот как выглядит перо:

UIView, названный закрепленным в наконечнике, является IBOutlet pinnedControls:

Когда я запускаю это в портретном режиме под iOS7 или iOS8, я получаю это:

И я вижу желаемый результат под iOS7 в ландшафтном режиме:

Но под iOS8 (GM) я не получаю такого поведения. Вот что я вижу вместо этого:

Обратите внимание, что центр UILabel с текстом «Закрепленная метка» сохраняет свое расстояние от нижней части закрепленного UIView, размер которого не изменился для размещения поворота. У этого UIView есть все его края, прикрепленные к верхней, левой, нижней и правой сторонам суперпредставления.

Мне кажется, что свойство transform взаимодействует с Auto Layout по-разному под iOS8. Я немного сбит с толку здесь. Я знаю, что не могу положиться на кадр. Я могу просто начать устанавливать границы вручную, но это кажется неправильным, по сути, сделать окончательный обход Auto Layout.

Ответы на вопрос(3)

Ваш ответ на вопрос