UITableView는 iOS 7에서 작동하지만 iOS 8에서는 깨져 보입니다. (UITableView works in iOS 7 but appears crushed in iOS 8)


문제 설명

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 HirsuteJimHirsuteJimLope)

참조 문서

  1. UITableView works in iOS 7 but appears crushed in iOS 8 (CC BY‑SA 3.0/4.0)

#uitableview #ios7 #ios8 #xcode6-beta6






관련 질문

레코드 삭제 중 오류 발생, 포착되지 않은 예외 'NSInternalInconsistencyException'으로 인해 앱 종료 (error while deleting records,Terminating app due to uncaught exception 'NSInternalInconsistencyException')

IOS 7에서 편집 상태의 셀을 반환하는 dequeueReusableCellWithIdentifier (dequeueReusableCellWithIdentifier returning cells in editing state in IOS 7)

UITableViewCell 탭 호버 (UITableViewCell tap hover)

ios swift tableview 셀 사이의 공간을 어떻게 변경할 수 있습니까? (How can I change the space between tableview cells ios swift)

테이블 뷰 셀을 선택할 때 뷰 컨트롤러를 푸시할 수 없습니다. (Can't push my view controller when I select a table view cell)

셀이 선택되면 UIImageView가 사라지지만 UILabel은 사라지지 않습니다. (UIImageView disappears but not UILabel when cell is selcted)

UITableView의 테두리를 설정하는 방법은 무엇입니까? (How to set a border for UITableView?)

plist에서 특정 데이터를 가져오는 UITableView(탐색 템플릿을 사용하지 않음) (UITableView (not using Navigation Template) getting specific data from plist)

searchBar의 일반 텍스트 버튼에 액세스하는 방법은 무엇입니까? (How to access searchBar's clear text button?)

'NSInternalInconsistencyException', 이유: '범위를 벗어난 섹션(0)에 대한 행 수를 요청했습니다.' ('NSInternalInconsistencyException', reason: 'Requested the number of rows for section (0) which is out of bounds.')

UITableViewCell에서 키보드 탭을 숨기는 UITapGestureRecognizer (UITapGestureRecognizer to hide keyboard taps on UITableViewCell)

특정 UITableViewCells에 고유한 삽입을 추가하는 방법은 무엇입니까? (How to add unique insets to specific UITableViewCells?)







코멘트