我有一个为 iOS 7 开发的餐厅菜单 iPad 应用程序,它使用collectionView
在横向模式下水平滚动。菜单部分标题如下所示:
这就是节标题视图的 xib 文件的样子:
我知道它看起来很奇怪,因为标签是水平的,但我正在旋转标签,因此标签的文本从下到上垂直。
//Rotate the sectionHeader label
[sectionHeader.headerLabel setTransform:CGAffineTransformMakeRotation(-M_PI/2)];
现在的问题是,在更新到 iOS9 后,标签根本不会显示在部分标题视图中:
这是我的部分标题代码:
- (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;
}
当我在上面注释“旋转节标题”行并将 xib 文件中的标签固定为垂直并匹配节标题视图的大小时,我得到以下问题,因为标签的文本应该从下到上垂直读取像第一个屏幕截图:
最后,我使用 Todd Laney 的stickyHeaderFlowLayout 使节标题具有粘性。
为什么iOS9会发生这种情况,我该如何解决?谢谢