12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- //
- // SettingsViewController.m
- // OpenLive
- //
- // Created by GongYuhua on 2016/9/12.
- // Copyright © 2016年 Agora. All rights reserved.
- //
- #import "SettingsViewController.h"
- #import "ProfileCell.h"
- #import <AgoraRtcEngineKit/AgoraRtcEngineKit.h>
- @interface SettingsViewController () <UITableViewDataSource, UITableViewDelegate>
- @property (weak, nonatomic) IBOutlet UITableView *profileTableView;
- @property (strong, nonatomic) NSArray *profiles;
- @end
- @implementation SettingsViewController
- #pragma mark 懒加载array
- - (NSArray *)profiles {
- if (!_profiles) {
- _profiles = @[@(AgoraRtc_VideoProfile_120P),
- @(AgoraRtc_VideoProfile_180P),
- @(AgoraRtc_VideoProfile_240P),
- @(AgoraRtc_VideoProfile_360P),
- @(AgoraRtc_VideoProfile_480P),
- @(AgoraRtc_VideoProfile_720P)];
- }
- return _profiles;
- }
- #pragma mark 重走table代理方法
- - (void)setVideoProfile:(AgoraRtcVideoProfile)videoProfile {
- _videoProfile = videoProfile;
- [self.profileTableView reloadData];
- }
- #pragma mark ok按钮
- //其实就是想要返回页面,代理可能会有一些其余操作
- - (IBAction)doConfirmPressed:(UIButton *)sender {
- if ([self.delegate respondsToSelector:@selector(settingsVC:didSelectProfile:)]) {
- [self.delegate settingsVC:self didSelectProfile:self.videoProfile];
- }
- }
- #pragma mark UITableViewDataSource
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return self.profiles.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- ProfileCell *cell = [tableView dequeueReusableCellWithIdentifier:@"profileCell" forIndexPath:indexPath];
- AgoraRtcVideoProfile selectedProfile = [self.profiles[indexPath.row] integerValue];
- [cell updateWithProfile:selectedProfile isSelected:(selectedProfile == self.videoProfile)];
-
- return cell;
- }
- #pragma mark UITableViewDelegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- AgoraRtcVideoProfile selectedProfile = [self.profiles[indexPath.row] integerValue];
- self.videoProfile = selectedProfile;
- }
- @end
|