Skip to content

Instantly share code, notes, and snippets.

@maxxfrazer
Created January 12, 2021 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxxfrazer/776ea8ab0933be0ebef9f1ab64de87a2 to your computer and use it in GitHub Desktop.
Save maxxfrazer/776ea8ab0933be0ebef9f1ab64de87a2 to your computer and use it in GitHub Desktop.
import UIKit
extension AgoraAudioViewController: UITableViewDelegate, UITableViewDataSource {
func createSpeakerTable() {
let newTable = UITableView()
self.view.addSubview(newTable)
newTable.frame = self.view.bounds
newTable.autoresizingMask = [.flexibleWidth, .flexibleHeight]
newTable.delegate = self
newTable.dataSource = self
newTable.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
self.speakerTable = newTable
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
section == 0 ? self.activeSpeakers.count : self.activeAudience.count
}
func numberOfSections(in tableView: UITableView) -> Int { 2 }
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
["Speakers", "Audience"][section]
}
func tableView(
_ tableView: UITableView, cellForRowAt indexPath: IndexPath
) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
let cellUserID = Array(
indexPath.section == 0 ? self.activeSpeakers : self.activeAudience
)[indexPath.row]
cell.textLabel?.text = self.usernameLookups[cellUserID]
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment