Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UICollectionViewCell内的UILabel帧等于CGRectZero_Ios_Storyboard_Uilabel_Frame_Cgrect - Fatal编程技术网

Ios UICollectionViewCell内的UILabel帧等于CGRectZero

Ios UICollectionViewCell内的UILabel帧等于CGRectZero,ios,storyboard,uilabel,frame,cgrect,Ios,Storyboard,Uilabel,Frame,Cgrect,我在我的应用程序中使用UICollectionView,我在UICollectionViewCell中使用了一些标签,我访问这些标签的方式如下: UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier: cellID forIndexPath: indexPath]; ... UILabel *nameLabel = (UILabel *)[cell viewWithTag: 2];

我在我的应用程序中使用UICollectionView,我在UICollectionViewCell中使用了一些标签,我访问这些标签的方式如下:

UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier: cellID forIndexPath: indexPath];
...
UILabel *nameLabel = (UILabel *)[cell viewWithTag: 2];
我的标签对每个UICollectionViewCell都有动态高度,因此我尝试检索
名称标签.frame
,但它总是给出
(x:0,y:0,h:0,w:0)
。 我试着改变标签的每一个可能的属性,但仍然一无所获。 顺便说一句,我可以设置文字和播放标签没有问题(IBOutlet设置正确)

UICollectionView、单元格和标签都是从故事板文件加载的

你们中有人在UILabels故事板上遇到过这个错误吗

编辑:
多亏了
verbumdei
的评论,我禁用了自动布局,它似乎解决了框架的这些问题。谢谢

您在哪里尝试记录帧?是否使用自动布局?已选中自动布局。我在检索到指向它的指针后立即记录它。我通过对单元格进行子类化,成功地解决了这个问题,很高兴问题得到了解决:)