Created
January 12, 2021 10:12
-
-
Save maxxfrazer/776ea8ab0933be0ebef9f1ab64de87a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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