Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. //
  2. // ViewController.m
  3. // FOO
  4. //
  5. // Created by JaminZhou on 2019/9/27.
  6. // Copyright © 2019 JaminZhou. All rights reserved.
  7. //
  8.  
  9. #import "ViewController.h"
  10.  
  11. @interface ViewController ()<UITableViewDataSource, UITableViewDelegate>
  12.  
  13. @end
  14.  
  15. @implementation ViewController
  16.  
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
  20. [self.view addSubview:tableView];
  21. tableView.dataSource = self;
  22. tableView.delegate = self;
  23. }
  24.  
  25. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  26. return 2;
  27. }
  28.  
  29. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  30. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  31. if (indexPath.row==0) {
  32. cell.layer.masksToBounds = YES;
  33. NSLog(@"Use cell.layer.masksToBounds = YES;");
  34. } else {
  35. cell.clipsToBounds = YES;
  36. NSLog(@"Use cell.clipsToBounds = YES;");
  37. }
  38. NSLog(@"cellForRowAtIndexPath: row = %@, masksToBounds = %d",@(indexPath.row), cell.layer.masksToBounds);
  39. return cell;
  40. }
  41.  
  42. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  43. NSLog(@"willDisplayCell: row = %@, masksToBounds = %d",@(indexPath.row), cell.layer.masksToBounds);
  44. }
  45.  
  46. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  47. NSLog(@"didSelectRowAtIndexPath=%@",[tableView cellForRowAtIndexPath:indexPath]);
  48. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  49. }
  50.  
  51. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement