Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ViewController.m
- // FOO
- //
- // Created by JaminZhou on 2019/9/27.
- // Copyright © 2019 JaminZhou. All rights reserved.
- //
- #import "ViewController.h"
- @interface ViewController ()<UITableViewDataSource, UITableViewDelegate>
- @end
- @implementation ViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
- [self.view addSubview:tableView];
- tableView.dataSource = self;
- tableView.delegate = self;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 2;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
- if (indexPath.row==0) {
- cell.layer.masksToBounds = YES;
- NSLog(@"Use cell.layer.masksToBounds = YES;");
- } else {
- cell.clipsToBounds = YES;
- NSLog(@"Use cell.clipsToBounds = YES;");
- }
- NSLog(@"cellForRowAtIndexPath: row = %@, masksToBounds = %d",@(indexPath.row), cell.layer.masksToBounds);
- return cell;
- }
- - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
- NSLog(@"willDisplayCell: row = %@, masksToBounds = %d",@(indexPath.row), cell.layer.masksToBounds);
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- NSLog(@"didSelectRowAtIndexPath=%@",[tableView cellForRowAtIndexPath:indexPath]);
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement