class DemoTableController: UIViewController,UITableViewDataSource,UITableViewDelegate {
@IBOutlet weak var answerView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
answerView.delegate = self
answerView.dataSource = self
answerView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "reuseIdentifier")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 5
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as! UITableViewCell
// Configure the cell...
return cell
}
I add the tableView to a view in a ViewController via StoryBoard.
And then I add a button to my prototype cell. The blank tableView does show up , but it's without the button.
Thank you in advance.
Delete this line,your code should work.Here you do not need
registerClass