문제 설명
UITableView는 iOS 7에서 작동하지만 iOS 8에서는 깨져 보입니다. (UITableView works in iOS 7 but appears crushed in iOS 8)
아직 iOS 프로그래밍이 처음입니다. iOS 7에서는 완벽하게 작동하지만 iOS 8에서는 부서진 것처럼 보이는 UITableView가 있습니다. 여러 장치. 시뮬레이터를 사용할 때도 동일한 문제/차이가 나타납니다(iOS 7 vs. iOS 8 시뮬레이터).
저는 Xcode 6 베타 6, Yosemite 베타 6, iOS 7.12 및 iOS 8 베타 5를 사용하고 있습니다.
p>문제를 보여주기 위해 코드를 최대한 간단하고 완전하게 만들었습니다.
‑ (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
‑ (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [self.numberOfDays count];
}
‑ (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier ];
NSLog (@"%li", (long)indexPath.row);
UILabel *label;
label = (UILabel *)[cell viewWithTag:1];
label.text = @"Monday";
return cell;
}
내 NSLog 문을 확인하십시오. 내 UIViewTable(0‑87)에는 88개의 행이 있습니다.
이 테이블이 iOS 7에서 로드되면...
- 콘솔에 12줄이 표시됩니다.
- 이후 그것이 초기에 볼 수 있는 행 수이기 때문입니다.
- 테이블 스크롤이 부드럽고 매끄럽습니다... 세상 모든 것이 좋습니다.
이 테이블이 iOS 8에서 로드될 때...
- 콘솔에 88줄이 표시됩니다.
- 어쨌든 이해가 되지 않습니다.
- 표의 초기 모양은 좋아 보입니다.
- 예: 처음 12개의 행이 올바르게 표시됩니다.
- 표가 올바르게 스크롤되지 않습니다.
- 12‑87행이 약 1픽셀 높이.< /li>
표를 스크롤할 때까지 표의 초기 모양은 괜찮아 보입니다(예: 처음 12행이 올바르게 표시됨). 그러면 행 12‑87이 약 1픽셀 높이로 나타납니다.
도와주세요!
좋아요 ‑ tableView.rowHeight = 44; 내 정적 NSString *CellIdentifier = @"Cell"; 선. iOS 7에서는 필요하지 않았지만 iOS 8에서는 왜 필요한지 잘 모르겠습니다.
내 정적 NSString *CellIdentifier = @"Cell"; 선. iOS 7에서는 필요하지 않았지만 iOS 8에서는 왜 필요한지 잘 모르겠습니다. 내 정적 NSString *CellIdentifier = @"Cell"; 선. iOS 7에서는 필요하지 않았지만 iOS 8에서는 왜 필요한지 잘 모르겠습니다.참조 솔루션
방법 1:
OK ‑ it was as simple as adding:
tableView.rowHeight = 44;
after my
static NSString *CellIdentifier = @"Cell";
line. I didn't need this is iOS 7, not sure why I need it in iOS 8.
방법 2:
Your solution might work, but it will be better to implement heightForRowAtIndexPath method
‑ (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
return 44;
}
I have no idea why there is difference between iOS 7 and 8, perhaps someone else could shed some light on that?
(by HirsuteJim、HirsuteJim、Lope)