抓娃娃版1127

SettingsViewController.m 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // SettingsViewController.m
  3. // OpenLive
  4. //
  5. // Created by GongYuhua on 2016/9/12.
  6. // Copyright © 2016年 Agora. All rights reserved.
  7. //
  8. #import "SettingsViewController.h"
  9. #import "ProfileCell.h"
  10. #import <AgoraRtcEngineKit/AgoraRtcEngineKit.h>
  11. @interface SettingsViewController () <UITableViewDataSource, UITableViewDelegate>
  12. @property (weak, nonatomic) IBOutlet UITableView *profileTableView;
  13. @property (strong, nonatomic) NSArray *profiles;
  14. @end
  15. @implementation SettingsViewController
  16. #pragma mark 懒加载array
  17. - (NSArray *)profiles {
  18. if (!_profiles) {
  19. _profiles = @[@(AgoraRtc_VideoProfile_120P),
  20. @(AgoraRtc_VideoProfile_180P),
  21. @(AgoraRtc_VideoProfile_240P),
  22. @(AgoraRtc_VideoProfile_360P),
  23. @(AgoraRtc_VideoProfile_480P),
  24. @(AgoraRtc_VideoProfile_720P)];
  25. }
  26. return _profiles;
  27. }
  28. #pragma mark 重走table代理方法
  29. - (void)setVideoProfile:(AgoraRtcVideoProfile)videoProfile {
  30. _videoProfile = videoProfile;
  31. [self.profileTableView reloadData];
  32. }
  33. #pragma mark ok按钮
  34. //其实就是想要返回页面,代理可能会有一些其余操作
  35. - (IBAction)doConfirmPressed:(UIButton *)sender {
  36. if ([self.delegate respondsToSelector:@selector(settingsVC:didSelectProfile:)]) {
  37. [self.delegate settingsVC:self didSelectProfile:self.videoProfile];
  38. }
  39. }
  40. #pragma mark UITableViewDataSource
  41. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  42. return self.profiles.count;
  43. }
  44. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  45. ProfileCell *cell = [tableView dequeueReusableCellWithIdentifier:@"profileCell" forIndexPath:indexPath];
  46. AgoraRtcVideoProfile selectedProfile = [self.profiles[indexPath.row] integerValue];
  47. [cell updateWithProfile:selectedProfile isSelected:(selectedProfile == self.videoProfile)];
  48. return cell;
  49. }
  50. #pragma mark UITableViewDelegate
  51. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  52. AgoraRtcVideoProfile selectedProfile = [self.profiles[indexPath.row] integerValue];
  53. self.videoProfile = selectedProfile;
  54. }
  55. @end