Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.57 KB | None | 0 0
  1. -(void)arrowButtonTapped:(UIButton *)donwbtn{
  2.  
  3. myob = [NSString stringWithFormat:@"%li", (long)donwbtn.tag];
  4. NSLog(@"%@",myob);
  5.  
  6. NSIndexPath * indexPath = [NSIndexPath indexPathForRow:0
  7. inSection:donwbtn.tag];
  8.  
  9. OppCell* celll = [_tableView cellForRowAtIndexPath:indexPath];
  10. celll.collView.tag=donwbtn.tag;
  11.  
  12.  
  13.  
  14. if ([checkcoll containsObject:myob]) {
  15. [checkcoll removeObject:myob];
  16. celll.collView.hidden = true;
  17. celll.collvwhght.constant=0;
  18. celll.colltop.constant=0;
  19. celll.collbottom.constant=0;
  20. }
  21.  
  22. else
  23. {
  24. [checkcoll addObject:myob];
  25. celll.collView.hidden = false;
  26. celll.collvwhght.constant=229;
  27. celll.colltop.constant=9;
  28. celll.collbottom.constant=8;
  29. [celll.collView reloadData] ;
  30.  
  31. }
  32.  
  33.  
  34. [self.tableView beginUpdates];
  35.  
  36. [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  37.  
  38. [self.tableView endUpdates];
  39.  
  40. }
  41.  
  42. -(UITableViewCell *)tableView:(UITableView *)tableView
  43. cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  44. OppCell *cell = (OppCell *)[tableView
  45. dequeueReusableCellWithIdentifier:@"OppCell"];
  46.  
  47. NSString *theIndexpath = [NSString stringWithFormat:@"%ld",
  48. (long)indexPath.section];
  49.  
  50. if ([checkcoll containsObject:theIndexpath])
  51. {
  52. cell.collView.hidden = false;
  53. cell.collvwhght.constant=229;
  54. cell.colltop.constant=9;
  55. cell.collbottom.constant=8;
  56.  
  57.  
  58. if((![[[_Activitylistarray
  59.  
  60. objectAtIndex:indexPath.section]
  61. valueForKey:@"OpportunityContactInfoList"]
  62. isKindOfClass:[NSNull class]])&&([[[_Activitylistarray
  63. objectAtIndex:indexPath.section]
  64. valueForKey:@"OpportunityContactInfoList"]count]>0)){
  65.  
  66.  
  67.  
  68. if(cell.contactdetailsarray == nil) {
  69. cell.contactdetailsarray =[[NSMutableArray alloc]init];
  70. for(NSDictionary * contactdict in
  71. [[_Activitylistarray objectAtIndex:indexPath.section]
  72. valueForKey:@"OpportunityContactInfoList"] ){
  73.  
  74. [cell.contactdetailsarray addObject:contactdict];
  75. [cell.collView reloadData];
  76. }
  77.  
  78. }
  79.  
  80.  
  81.  
  82.  
  83. }
  84.  
  85. }
  86. else
  87. {
  88. cell.collView.hidden = true;
  89. cell.collvwhght.constant=0;
  90. cell.colltop.constant=0;
  91. cell.collbottom.constant=0;
  92.  
  93. // [cell.contactdetailsarray removeAllObjects];
  94. // [cell.collView reloadData];
  95. }
  96.  
  97. ////Code in UITableViewCell
  98.  
  99. #import "OppCell.h"
  100. #import "OppsContactCell.h"
  101.  
  102. @implementation OppCell
  103.  
  104. - (void)awakeFromNib {
  105. [super awakeFromNib];
  106. // Initialization code
  107.  
  108. [self.collView registerNib:[UINib nibWithNibName:@"OppsContactCell"
  109. bundle:nil] forCellWithReuseIdentifier:@"OppsContactCell"];
  110. self.collView.pagingEnabled = YES;
  111.  
  112. UICollectionViewFlowLayout * layout=[[UICollectionViewFlowLayout
  113. alloc]init];
  114.  
  115. layout.scrollDirection=UICollectionViewScrollDirectionHorizontal;
  116. self.collView.collectionViewLayout = layout;
  117. self.collView.decelerationRate =
  118. UIScrollViewDecelerationRateNormal;
  119.  
  120. // _contactdetailsarray=[NSMutableArray array];
  121.  
  122. // self.collvwhght.constant=0;
  123. //self.collView.hidden=YES;
  124. }
  125.  
  126. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  127. [super setSelected:selected animated:animated];
  128.  
  129. // Configure the view for the selected state
  130. }
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. - (UICollectionViewCell *)collectionView:(UICollectionView
  138. *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  139.  
  140. OppsContactCell *cell = [collectionView
  141. dequeueReusableCellWithReuseIdentifier:@"OppsContactCell"
  142. forIndexPath:indexPath];
  143.  
  144.  
  145. cell.contactimgvw.image = [cell.contactimgvw.image
  146. imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
  147. [cell.contactimgvw setTintColor:[UIColor blackColor]];
  148.  
  149. cell.numberimgvw.image = [cell.numberimgvw.image
  150. imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
  151. [cell.numberimgvw setTintColor:[UIColor blackColor]];
  152.  
  153. cell.emailimgvw.image = [cell.emailimgvw.image
  154. imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
  155. [cell.emailimgvw setTintColor:[UIColor blackColor]];
  156.  
  157.  
  158.  
  159. if(_contactdetailsarray.count==1){
  160.  
  161.  
  162.  
  163. if(([[[_contactdetailsarray
  164. objectAtIndex:0]valueForKey:@"Designation"]isEqualToString:@""])&&([[[_contactdetailsarray
  165. objectAtIndex:0]valueForKey:@"Department"]isEqualToString:@"" ])){
  166.  
  167. cell.lbldesignation.text=@"";
  168.  
  169. }
  170.  
  171. else{
  172.  
  173. cell.lbldesignation.text=[NSString stringWithFormat:@"%@,%@",
  174. [[_contactdetailsarray objectAtIndex:0]valueForKey:@"Designation"],
  175. [[_contactdetailsarray objectAtIndex:0]valueForKey:@"Department"]];
  176.  
  177. }
  178.  
  179. cell.lblcontatname.text=[[_contactdetailsarray
  180. objectAtIndex:0]valueForKey:@"ContactName"];
  181. cell.lblcontactnumber.text=[[_contactdetailsarray
  182. objectAtIndex:0]valueForKey:@"TelephoneNo"];
  183. cell.lblemail.text=[[_contactdetailsarray
  184. objectAtIndex:0]valueForKey:@"EmailAddress"];
  185. }
  186.  
  187. else{
  188.  
  189.  
  190. if(([[[_contactdetailsarray
  191. objectAtIndex:0]valueForKey:@"Designation"]isEqualToString:@""])&& .
  192. ([[[_contactdetailsarray
  193. objectAtIndex:0]valueForKey:@"Department"]isEqualToString:@"" ])){
  194. cell.lbldesignation.text=@"";
  195.  
  196. }
  197.  
  198.  
  199. else{
  200. cell.lbldesignation.text=[NSString stringWithFormat:@"%@,%@",
  201. [[_contactdetailsarray
  202. objectAtIndex:indexPath.section]valueForKey:@"Designation"],
  203. [[_contactdetailsarray
  204. objectAtIndex:indexPath.section]valueForKey:@"Department"]];
  205. }
  206.  
  207. cell.lblcontatname.text=[[_contactdetailsarray
  208. objectAtIndex:indexPath.row]valueForKey:@"ContactName"];
  209. cell.lblcontactnumber.text=[[_contactdetailsarray
  210. objectAtIndex:indexPath.row]valueForKey:@"TelephoneNo"];
  211. cell.lblemail.text=[[_contactdetailsarray
  212. objectAtIndex:indexPath.row]valueForKey:@"EmailAddress"];
  213. }
  214.  
  215.  
  216. return cell;
  217.  
  218. }
  219.  
  220.  
  221.  
  222. - (CGSize)collectionView:(UICollectionView *)collectionView
  223. layout:(UICollectionViewLayout *)collectionViewLayout
  224. sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  225. {
  226.  
  227.  
  228.  
  229.  
  230. return CGSizeMake(_collView.bounds.size.width
  231. ,_collView.bounds.size.height);
  232.  
  233. }
  234.  
  235. - (CGFloat)collectionView:(UICollectionView *)collectionView
  236. layout:(UICollectionViewLayout*)collectionViewLayout
  237. minimumLineSpacingForSectionAtIndex:(NSInteger)section
  238. {
  239. return 5;
  240. }
  241.  
  242. - (NSInteger)collectionView:(UICollectionView *)collectionView
  243. numberOfItemsInSection:(NSInteger)section{
  244.  
  245. // return 5;
  246.  
  247.  
  248. if(_contactdetailsarray.count==0){
  249. return 0;
  250. }
  251.  
  252. else{
  253. return _contactdetailsarray.count;
  254. }
  255.  
  256. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement