내 코드 :cellForRowAt가 호출되고
//Adding Destination VC as subview in my current view's view container
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier: "DestinationViewControllerID")
containerView.addSubview(viewController.view)
viewController.didMove(toParentViewController: self)
//Now implementing Table view in the destination vc
class DestinationViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var tableView = UITableView()
var tableData = ["Beach", "Clubs", "Chill", "Dance"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let screenBounds = UIScreen.main.bounds
let rect = CGRect(x: 0, y: 0, width: screenBounds.width, height: screenBounds.height)
tableView = UITableView(frame: rect, style: UITableViewStyle.plain)
tableView.dataSource = self
tableView.delegate = self
tableView.backgroundColor = UIColor.blue
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "my")
view.addSubview(tableView)
tableView.reloadData()
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "my", for: indexPath)
cell.textLabel?.text = "This is row \(tableData[indexPath.row])"
return cell
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 4//tableData.count
}
}
그때 모든 것이 좋으을 작동하고 스토리 보드에서 내 초기 VC로 대상의 ViewController를 설정하고있어 경우에 경우에 하위 뷰를 같이 추가 container view cellForRowAt 메서드가 호출되지 않고 numberOfSection 및 numberOfRowsInSection이 호출됩니다.
해결책이있는 사람이 있습니까?
당신은 당신의 UIViewController.View –
신속한 버전은 무엇에 jQuery과를 추가해야합니까? – User511
서브 뷰에 추가하기 전에 테이블 뷰를 새로 고침 – Jaydip