Objective-C에서 수 백만 번을 수행했지만 Swift가 예상대로 작동하지 않습니다. 다음 코드는 하나의 행으로 jQuery과 셀을 채우지 않습니다 : 나는 budgetLabel 스토리 보드에 올바르게 연결된되어 있는지 확인 만든UITableView에 사용자 지정 UITableViewCell 채우기 Swift 언어 사용
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
var cell = tableView.dequeueReusableCellWithIdentifier("BudgetTableViewCell", forIndexPath: indexPath) as BudgetTableViewCell
cell.budgetTitle.text = "My Budget"
return cell
}
override func numberOfSectionsInTableView(tableView: UITableView?) -> Int {
return 1;
}
override func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) -> Int {
return 1;
}
. 위의 모든 메소드가 호출되지만 UITableView가로드 될 때 아무 것도 표시되지 않습니다.
있는 UITableViewController 템플릿 애플이 제공 :
// #pragma mark - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView?) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 0
}
override func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 0
}
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell? {
let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath)
// Configure the cell...
return cell
}
john doe, 나는 당신이 당신의 질문에 대답하기에 충분한 정보를 제공하지 않는다고 생각합니다. 예를 들어, 재사용 식별자에 대한 클래스를 등록 했습니까? 위임자를 구성 했습니까? 디버그 중단 점을 설정하여 코드가 호출되었는지 확인 했습니까? –
디버깅을했고 코드가 호출되었습니다. Storyboard를 사용하여 클래스를 UITableViewCell에 등록했습니다. –
흥미 롭습니다! 아마도이 문제는 BudgetTableViewCell 클래스에 있습니까? 콘솔에 어떤 레이아웃 경고가 전송 되었습니까? 뷰 계층 구조를 덤프하는 것은 약간의 빛을 줄 수도 있습니다. –