2016-09-29 3 views
0

Xib (autolayout)에 의해 생성 된 사용자 정의 셀로 채워진 UITableView가 있습니다. 셀은 여러 레이블 이미지 등으로 구성되며 응답에 따라 크기가 변경됩니다 우리는 api에서 나옵니다. 나는 열심히 높이 설정하려고 노력해 왔습니다. 나는 다음과 같은 방법을 사용하고있다.스위치에서 사용자 정의 UITabelview 셀의 동적 높이를 설정하는 방법

func createTabelView() 
    { 
    let nib = UINib(nibName: "DBEventCell", bundle: nil) 
     self.eventTabelVew.registerNib(nib, forCellReuseIdentifier: Constants.CELL_IDENTIFIER) 

     self.eventTabelVew.estimatedRowHeight = 200 
     self.eventTabelVew.rowHeight = UITableViewAutomaticDimension 
     self.eventTabelVew.separatorStyle = .None //UITableViewCellSeparatorStyle.SingleLine; 
     self.eventTabelVew.separatorColor = UIColor.clearColor(); 
     self.eventTabelVew.backgroundColor = UIColor.whiteColor(); 

     self.eventTabelVew.setNeedsLayout() 
     self.eventTabelVew.layoutIfNeeded() 
    } 


func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat 
    { 
    return UITableViewAutomaticDimension 
    } 
func tableView(tleView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { 

     return UITableViewAutomaticDimension 
    } 

그러나 이것은 작동하지 않습니다. 제가 지난 며칠 동안 마지막으로 쳤을 때 도움을주십시오. 사전에 덕분에

답변

0

난 당신이 자습서를 확인도

func tableView(tleView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { 

    return UITableViewAutomaticDimension 
} 

당신이 제약을 자동 레이아웃 셀을 확인해야하고 UI 구성 요소의 특성을 조정하는 것은 그것을 계약을 체결하거나 콘텐츠로 확장이 기능이 필요하지 않습니다 생각 이 기능 estimatedHeightForRowAtIndexPath를 제거 여전히 문제가 그대로있는 경우

https://www.appcoda.com/self-sizing-cells/

+0

는 또한 "https://www.appcoda.com/self-sizing-cells/"에 튜토리얼을 따라하지하지만 더했다 일한 사람 –