UICollectionView 部分 Header 视图在 iOS9 中未正确旋转

UICollectionView Section Header view doesn't rotate properly in iOS9

我有一个为 iOS 7 开发的餐厅菜单 iPad 应用程序,它使用 collectionView 在横向模式下水平滚动。菜单部分 header 如下所示:

这就是 header 视图部分的 xib 文件的样子:

我知道它看起来很奇怪,因为标签是水平的,但我正在旋转标签,使标签的文本从下到上垂直。

//Rotate the sectionHeader label
[sectionHeader.headerLabel setTransform:CGAffineTransformMakeRotation(-M_PI/2)];

现在的问题是,更新到 iOS9 后,标签在 header 视图部分根本不显示:

这是我在 header:

部分的代码
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    //UICollectionReusableView *reusableview = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];

    SectionHeader *sectionHeader = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"MyHeaderID" forIndexPath:indexPath];



    //Load the Menu Sections from the menuSections Array
    MenuSection *menuSection = [[MenuSection alloc] init];
    menuSection = [self.menuSections objectAtIndex:indexPath.section];

    //Rotate the sectionHeader label
    [sectionHeader.headerLabel setTransform:CGAffineTransformMakeRotation(-M_PI/2)];

    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"LanguageArabic"] == NO)
    {
        sectionHeader.headerLabel.text = [NSString stringWithFormat:@"%@", menuSection.sectionName];
    }
    else
    {
        sectionHeader.headerLabel.text = [NSString stringWithFormat:@"%@", menuSection.sectionNameArabic];
    }

    return sectionHeader;
}

当我评论上面的 "Rotate section header" 行并将 xib 文件中的标签固定为垂直并匹配部分 header 视图的大小时,我得到以下内容,这是一个问题,因为标签的文本应该像第一个屏幕截图一样从下到上垂直阅读:

最后,我正在使用 Todd Laney 的 stickyHeaderFlowLayout 来使 header 部分变得粘滞。

为什么 iOS9 会出现这种情况,我该如何解决? 谢谢

当您应用旋转变换时,它会围绕其中心点旋转视图。您需要做的是在您的 xib 文件中设置标签的约束,以将其垂直和水平固定到超级视图的中心。然后当然你仍然在你的代码中应用旋转变换。这应该可以解决问题。