SelectionTableViewCell.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // SelectionTableViewCell.m
  3. // TTSDemo
  4. //
  5. // Created by lappi on 3/16/16.
  6. // Copyright © 2016 baidu. All rights reserved.
  7. //
  8. #import "SelectionTableViewCell.h"
  9. @implementation selectionCellContext
  10. -(instancetype)initWithName:(NSString*)name{
  11. self = [super init];
  12. if(self){
  13. self.isSelected = NO;
  14. self.itemName = name;
  15. }
  16. return self;
  17. }
  18. -(void)setSelectionState:(BOOL)isSelected{
  19. self.isSelected = isSelected;
  20. if(self.ContextUI){
  21. [self.ContextUI.SelectionStateView setHidden:!isSelected];
  22. }
  23. }
  24. @end
  25. @implementation SelectionTableViewCell
  26. -(void)setContext:(selectionCellContext*)ctx{
  27. if(self.cellContext && self.cellContext.ContextUI == self){
  28. self.cellContext.ContextUI = nil;
  29. }
  30. self.cellContext = ctx;
  31. if(self.cellContext){
  32. self.cellContext.ContextUI = self;
  33. [self.nameLabel setText:self.cellContext.itemName];
  34. [self.SelectionStateView setHidden:!self.cellContext.isSelected];
  35. }
  36. }
  37. - (void)awakeFromNib {
  38. // Initialization code
  39. [super awakeFromNib];
  40. self.SelectionStateView.layer.cornerRadius = 10;
  41. }
  42. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  43. [super setSelected:selected animated:animated];
  44. // Configure the view for the selected state
  45. }
  46. @end