zoukankan      html  css  js  c++  java
  • 表格视图

    1. 实现UITableViewDelegate协议

    @interface ViewController () <UITableViewDelegate>

    2. 将表格视图的代理属性指向其父容器视图

    self.myTableView.delegate = self;

    3. 实现协议对应的方法

    tableView:heightForRowAtIndexPath:

    完整代码(ViewController.m):

    #import "ViewController.h"
    
    @interface ViewController () <UITableViewDelegate>
    @property (nonatomic, strong) UITableView *myTableView;
    @end
    
    @implementation ViewController
        
    - (CGFloat)     tableView:(UITableView *)tableView
      heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        if ([tableView isEqual:self.myTableView]){
            return 100.0f;
        }
        return 40.0f;
    }
        
    - (void)viewDidLoad{
        [super viewDidLoad];
        
        self.myTableView = [[UITableView alloc]
                            initWithFrame:self.view.bounds
                            style:UITableViewStylePlain];
        
        self.myTableView.delegate = self;
        
        [self.view addSubview:self.myTableView];
        
    }
    
    @end
  • 相关阅读:
    B+树实现
    一些比较特殊的计数序列
    codeforce刷题(六)
    codeforces刷题(五)
    Swap and Flip
    leetcode刷题(三)
    leetcode刷题(二)
    leetcode刷题(一)
    C语言学习笔记-变量存储
    水笔记
  • 原文地址:https://www.cnblogs.com/davidgu/p/5053484.html
Copyright © 2011-2022 走看看