안녕 얘들 아, 여기 좀 곤란 해. 그리드 디스플레이를 만드는보기가 있습니다. 내 말은, 나는 9 개의 항목을 가지고 있고, 한 줄에 3 개를 표시하도록 설정되어있다. 3 줄로 결과. 괜찮아. 내가 understang하지 않는 것은, 왜 항상 그들 사이에 공간을 얻을 수 있습니다. 때로는 라인의 중간에 올라옵니다. 이 공간은 한 줄의 높이와 같습니다.Objective-C : 논리 질문
체크 코드 :
[] [] []
[] [] []
[] [] []
NSInteger quantidadeDeVideos = [self.videosURL count];
NSInteger contadorDeVideos = 0;
NSInteger idLinha = 0;
NSInteger linha = 1;
NSInteger itemq = 0;
while (contadorDeVideos < quantidadeDeVideos) {
float f;
float g;
// Set the lines
if (itemq < 3) {
itemq++;
}
else {
itemq = 1;
linha++;
}
// This makes the second line multiplies for 150;
if (linha > 1) {
g = 150;
}
else {
g = 0;
}
// Ignore this, this is foi make 1,2,3. Making space between the itens.
if (idLinha > 2) {
idLinha = 0;
}
NSLog(@"%i", foi);
float e = idLinha*250+15;
f = linha*g;
UIImageView *thumbItem = [[UIImageView alloc] init];
thumbItem.frame = CGRectMake(e, f, 231, 140);
UIColor *bkgColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"VideosItemBackground.png"]];
thumbItem.backgroundColor = bkgColor;
thumbItem.opaque = NO;
[self.videosScroll addSubview:thumbItem];
contadorDeVideos++;
idLinha++;
}
이 결과이어야 인
그리고 이것은 내가 갖는 것입니다 :
[] [] []
[] [] [] [] []
[] [] []
모두를위한 감사합니다!
아, 그게 효과가 있었어! 나는 단지 이것을 보지는 못했다. 고마워요! –
+1 좋은 설명. –