I programmatically created a UITableView for a custom keyboard extension within the default KeyboardViewController.swift but for some reason the didSelectRowAtIndexPath is not responding at all. I've made sure to set the userInteractionEnabled to true for both the table the cells and made sure to set allowsSelectionDuringEditing to true. The tableView is definitely being populated and the cells get highlighted when I touch them but the logs are not appearing at all (nor is the method breaking when there is a breakpoint on it).
Anyone have any ideas on what I may have screwed up to make this happen?
class KeyboardViewController: UIInputViewController, UITableViewDelegate, UITableViewData Source {
var tableView: UITableView = UITableView()
//other setup
override func viewDidLoad() {
super.viewdidLoad
// other setup here
tableView.frame = CGRectMake(0, 0, 320, 160)
tableView.delegate = self
tableView.dataSource = self
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
tableView.allowsSelection = true
tableView.allowsSelectionDuringEditing = true
tableView.userInteractionEnabled = true
self.view.addSubview(tableView)
}
//delegate&datasource methods
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let sectionTitle = artistSectionTitles[section]
let sectionArtist = artists[sectionTitle]
return sectionArtist!.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
cell.userInteractionEnabled = true
let sectionTitle = artistSectionTitles[indexPath.section]
let sectionArtists = artists[sectionTitle]
let artist = sectionArtists?[indexPath.row] as NSString
cell.textLabel?.text = artist
return cell
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 22
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: false)
println("You selected cell #\(indexPath.row)!")
}
func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return artistSectionTitles[section]
}
func sectionIndexTitlesForTableView(tableView: UITableView) -> [AnyObject]! {
return artistSectionTitles
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return artistSectionTitles.count
}