pod 'SeatGridView'
dependency to your Podfile
file.target 'xxxx' do......pod 'SeatGridView'end
Podfile
file, first cd
in Terminal into the xxxx.xcodeproj
directory, then create one using the following command:pod init
cd
into the Podfile
directory and then run the following command to install components.pod install
pod repo update
pod update
//// AppDelegate.swift//import TUICorefunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {TUILogin.login(1400000001, // Please replace with the SDKAppID obtained in Step 1userID: "denny", // Please replace with your UserIDuserSig: "xxxxxxxxxxx") { // You can calculate a UserSig in the console and fill it hereprint("login success")} fail: { (code, message) inprint("login failed, code: \\(code), error: \\(message ?? "nil")")}return true}
Parameter | Type | Description |
SDKAppID | int | You have already obtained it in the last step of Step 1, so it will not be elaborated here. |
UserID | String | The ID of the current user, in string format, only allows letters (a-z and A-Z), digits (0-9), hyphens, and underscores. |
userSig | String | Use the SecretKey obtained in step 3 of Step One to encrypt information such as SDKAppID and UserID to generate a UserSig. It's a credential used for authentication purposes, allowing Tencent Cloud to identify if the current user is authorized to use the TRTC service. You can generate a temporary UserSig through the Auxiliary Tools in the console. For more information, please refer to How to Calculate and Use UserSig. |
GenerateTestUserSig.genTestSig
function to generate userSig. In this method, the SDKSecretKey is vulnerable to decompilation and reverse engineering, and once your key is leaked, attackers can steal your Tencent Cloud traffic.let seatGridView = SeatGridView(this)
let roomInfo = TUIRoomInfo()roomInfo.roomId = "123456"seatGridView.startVoiceRoom(roomInfo) { roomInfo in} onError: { code, message in}seatGridView.startMicrophone() {} onError: { code,message in}
seatGridView.joinVoiceRoom("roomId_123456") { roomInfo in} onError: { code, message in}
Anchor starts the live streaming room and begins the live stream | Audience joins the live streaming room to watch the live stream |
|
|
// Set grid layoutseatGridView.setLayoutMode(layoutMode: .grid)// Set element layoutseatGridView.setLayoutMode(layoutMode: .focus)// Set vertical layoutseatGridView.setLayoutMode(layoutMode: .vertical)// Set custom layout// First row configurationlet rowConfig1 = SGSeatViewLayoutRowConfig(count: 3, //Number of seats displayed in the first rowseatSpacing: 10, //Horizontal spacing between each seat in the first rowseatSize: CGSize(width: 50, height: 50), //Size of each seat view displayed in the first rowalignment: .center) //Alignment of seats in the first row// Second row configurationlet rowConfig1 = SGSeatViewLayoutRowConfig(count: 3, //Number of seats displayed in the second rowseatSpacing: 10, //Horizontal spacing between each seat in the second rowseatSize: CGSize(width: 50, height: 50), //Size of each seat view displayed in the second rowalignment: .spaceAround) //Alignment of seats in the second rowlet layoutConfig = SGSeatViewLayoutConfig(rowConfigs: [rowConfig1, rowConfig2],rowSpacing: 10)seatGirdView.setLayoutMode(.free, layoutConfig)
Grid Layout | Element Layout | Vertical Layout | Custom Layout |
| |
|
|
class TestSeatViewDelegate: SGSeatViewDelegate {func seatGridView(_ view: SeatGridView, createSeatView seatInfo: TUISeatInfo) -> UIView? {return TestSeatInfoView(seatGirdView: seatGridView, seatInfo: seatInfo)}func seatGridView(_ view: SeatGridView, updateSeatView seatInfo: TUISeatInfo, seatView: UIView) {if let seatView = seatView as? TestSeatInfoView {seatView.updateSeatView(seatGirdView: seatGridView, seatInfo: seatInfo)}}func seatGridView(_ view: SeatGridView, updateUserVolume volume: Int, seatView: UIView) {if let seatView = seatView as? TestSeatInfoView {seatView.updateUserVolume(seatGirdView: seatGridView, volume: volume)}}}seatGirdView.setSeatViewDelegate(TestSeatViewDelegate())class TestSeatInfoView: UIView {init(seatGirdView: SeatGridView, seatInfo: TUISeatInfo) {super.init(frame: .zero)initView() //Initialize view}func updateSeatView(seatGirdView: SeatGridView, seatInfo: TUISeatInfo) {updateView(seatInfo) //Update custom seat view UI}func updateUserVolume(seatGirdView: SeatGridView, volume: Int) {updateUserVolume(volume) //Update volume change UI}}
Before customizing the seat layout | After customizing the seat layout |
|
|
Was this page helpful?