ThingsAddViewController.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //
  2. // ThingsAddViewController.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 5/8/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "RequestHandler.h"
  10. #import "DeviceModel.h"
  11. #import "CustomLabel.h"
  12. #import "CustomButton.h"
  13. #import "CustomImageView.h"
  14. #import "ThingsAddWallpadSubViewController.h"
  15. #import "ThingsAddViewController.h"
  16. @implementation ThingsAddTableViewCell
  17. @end
  18. @interface ThingsAddViewController () {
  19. NSInteger _rowCount;
  20. }
  21. @end
  22. #pragma mark - Class Definition
  23. @implementation ThingsAddViewController
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. // Do any additional setup after loading the view.
  27. [self initUI];
  28. [self prepareViewDidLoad];
  29. }
  30. - (void)viewWillAppear:(BOOL)animated {
  31. [super viewWillAppear:animated];
  32. }
  33. - (void)initUI {
  34. [self initTableViewAsDefaultStyle:_tableView];
  35. }
  36. - (void)prepareViewDidLoad {
  37. }
  38. #pragma mark - Main Logic
  39. #pragma mark - UITableView DataSource & Delegate
  40. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  41. return 2;
  42. }
  43. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  44. ThingsAddTableViewCell *cell = (ThingsAddTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"AddCellIdentifier"];
  45. if (indexPath.row == 0) {//
  46. if (![cell.btnAdd actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  47. [cell.btnAdd addTarget:self action:@selector(btnAddSmartPlugTouched:) forControlEvents:UIControlEventTouchUpInside];
  48. }
  49. } else if (indexPath.row == 1) {//
  50. if (![cell.btnAdd actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  51. [cell.btnAdd addTarget:self action:@selector(btnAddMultiSensorTouched:) forControlEvents:UIControlEventTouchUpInside];
  52. }
  53. }
  54. return cell;
  55. }
  56. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  57. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  58. if (indexPath.row == 0) {
  59. [self btnAddSmartPlugTouched:nil];
  60. } else if (indexPath.row == 1) {
  61. [self btnAddMultiSensorTouched:nil];
  62. }
  63. }
  64. #pragma mark - TableView Delegate
  65. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  66. // Remove seperator inset
  67. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  68. [cell setSeparatorInset:UIEdgeInsetsZero];
  69. }
  70. // Prevent the cell from inheriting the Table View's margin settings
  71. if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
  72. [cell setPreservesSuperviewLayoutMargins:NO];
  73. }
  74. // Explictly set your cell's layout margins
  75. if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
  76. [cell setLayoutMargins:UIEdgeInsetsZero];
  77. }
  78. }
  79. #pragma mark - UI Events
  80. - (void)btnAddSmartPlugTouched:(id)sender {
  81. }
  82. - (void)btnAddMultiSensorTouched:(id)sender {
  83. }
  84. - (IBAction)btnCloseTouched:(id)sender {
  85. [self dismissViewControllerAnimated:YES completion:nil];
  86. }
  87. #pragma mark - MemoryWarning
  88. - (void)didReceiveMemoryWarning
  89. {
  90. [super didReceiveMemoryWarning];
  91. // Dispose of any resources that can be recreated.
  92. }
  93. @end