gpt4 book ai didi

ios - UICollectionView 框架变化

转载 作者:可可西里 更新时间:2023-11-01 06:24:41 25 4
gpt4 key购买 nike

我在 SO 上看到的答案似乎都没有回答这个问题。我正在尝试更改 UICollectionView 的框架。记录时会显示帧更改,但不会实际更改帧。我没有对其设置任何限制。只是改变框架。就这样。我正在创建一个不可滚动的 UICollectionView

    _testStringOne = @"Test String";
_tagOne = [_testStringOne boundingRectWithSize:CGSizeMake(242.0f, 900.0f) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:15.0f]} context:nil];

_testStringTwo = @"Another Test String";
_tagTwo = [_testStringTwo boundingRectWithSize:CGSizeMake(242.0f, 900.0f) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:15.0f]} context:nil];

CGRect collectionFrame = self.collectionView.frame;
if (_tagOne.origin.x + _tagOne.size.width + _tagTwo.origin.x + _tagTwo.size.width > 242.0f)
{
collectionFrame.size.height = 62.0f;
sectionCount = 2;
itemCount = 1;
}
else
{
collectionFrame.size.height = 31.0f;
sectionCount = 1;
itemCount = 2;
}
self.collectionView.frame = collectionFrame;
[self.collectionView reloadData];

最佳答案

在纵向和横向方向之间切换时,我遇到了类似的问题。之后工作正常

self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleWidth;

关于ios - UICollectionView 框架变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21043586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com