UIViewController
의 사용자 지정 하위보기로 UITableView
을 만들려고하지만 데이터가 테이블에 나타나지 않습니다. 문제가 내 delegate
이고 datasource
이 테이블에 설정되어 있지 않은 것 같습니다. 어떻게 그들을 연결할 수 있습니까? UITableViewDataSource
은 UITableView
클래스에서 작동하지 않는 것 같습니다.사용자 지정 UITableView에서 대리자 및 데이터 소스 설정
의 UIViewController
let projectDeck = ProjectDeck()
projectDeck.frame = CGRect(x: 0, y: statusBarHeight + 132, width: screenWidth, height: screenHeight - 132)
self.view.addSubview(projectDeck)
jQuery과
class ProjectDeck: UITableView {
var items = ["Test", "TestTest", "TestBestWestVest"]
override func numberOfRows(inSection section: Int) -> Int {
return items.count
}
override func cellForRow(at indexPath: IndexPath) -> UITableViewCell? {
let cell = UITableViewCell()
cell.textLabel?.text = items[indexPath.row]
return cell
}
}
projectDeck.delegate = self, datasource (UIViewController가 위임자 또는 데이터 소스 인 경우)와 동일합니다. ** 기억 ** ** tableView 셀의 높이를 정확하게 지정해야합니다. https://developer.apple.com/reference/uikit/uitableviewdelegate/1614998-tableview –
[Swift에서 프로그래밍 방식으로 [위젯 및 데이터 소스를 설정]의 가능한 복제본 (http://stackoverflow.com/questions/27022136/set-delegate) -and-data-source-of-swable) –
셀을 큐에서 제거하는 방법 : http://stackoverflow.com/questions/24471954/how-to-use-dequeuereusablecellwithidentifier-in-swift –