전화 번호 블록을 표시하는 UICollectionViewController가 있습니다 (이미지 참조). 보기가로드 될 때 그들은 모두 스크롤을 시작하거나, 회전을 변경하거나, 데이터가 소싱되는 (변경 가능한) 배열을 변경하는 검색 함수를 실행할 때 모두 잘 나타납니다. 잘못된 형식의 레이블을 참조하십시오. 나는 그것이 iOS 시뮬레이터일지도 모른다고 생각했지만, UICollectionViewCells의 위치에 문제가있는 것처럼 보였다.iOS, UICollectionViewCell 형식이 잘못된 UILabel
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"cell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
cell.backgroundColor = [UIColor grayColor];
cell.layer.cornerRadius = 5;
[cell setClipsToBounds: YES];
CGRect cellBound = CGRectMake(25, 12.5, 150, 12.5); // x, y, w, h
UILabel *title = [[UILabel alloc] initWithFrame:cellBound];
NSString *number = [[searchNumbers objectAtIndex:indexPath.row] valueForKey:@"number"];
number = [number stringByReplacingOccurrencesOfString:@"+44" withString: @"0"];
title.text = number;
[cell addSubview:title];
return cell;
}
당신이 (또 다시 cellForItemAtIndexPath
이기 때문에 휴대에 더 많은 UILabel
파단으로 추가되기 때문에 이런 일이 생각 난 UICollectionViewFlowLayout
당신은 완전히 맞습니다 :) 내 대답은 잘못된 것을 올바른 방법으로 설명하는 것이 아니라 upvoted를 설명합니다! – Woodstock
이것을 달성하는 아주 좋은 방법 :) –