0
連絡先やApple Musicのスクロールバーのようなアルファベット順のスクロールバーを作成しようとしています。ただし、sectionIndexTitlesForTableView
メソッドを呼び出すと、アルファベットのスクロールバーが表示されません。これをどうやって解決するのですか?私はこれをolder tutorialとnewer tutorialと言いました。アルファベット順のスクロールバーが表示されない
コード
class SongsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
private var sectionTitles = ["A", "B", "C"]
func sectionIndexTitlesForTableView(tableView: UITableView) -> [AnyObject]! {
return sectionTitles as [AnyObject]
}
func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {
return sectionTitles.index(of: title)!
}
}