别人的分享

//    UITableView //    UITableView继承于UIScrollView,可以滚动。 UITableView的每一条数据对应的单元格叫做Cell,是UITableViewCell一个对象,继承于UIView。 //    UITabbeView可以分区显⽰示, 每一个分区称为section, 每一⾏称为row, 编号都从0开始。 系统提供了一个专门的类来整合section和row,叫做NSIndexPath。

//创建UITableView

   UITableView *tableView = [[UITableView alloc]                              initWithFrame:self.view.bounds                              style:UITableViewStylePlain];    [self.view addSubview:tableView];    [tableView release];

//UITableView的样式枚举

  // UITableView的初始化⽅方法包含⼀一个UITableViewStyle类型的参数 这是⼀一个枚举类型    typedef NS_ENUM(NSInteger, UITableViewStyle) {        UITableViewStylePlain,        UITableViewStyleGrouped    };

//UITableView的相关属性

   //rowHeight        行高

   //separtorStyle    分隔线样式

   //separtorColor    分隔线颜⾊

   //tableHeaderView  UITableView的置顶视图

   //tableFooterView  UITableView的置底视图

//UITableView中有两个重要的属性:

   @property (nonatomic, weak, nullable) id     dataSource;

    //dataSource 显示数据相关的代理    @property (nonatomic, weak, nullable) id     delegate;

    //delegate   视图操作相关的代理

//UITableView代理的实现代码

   1.签订UITableView协议    2.设置当前的ViewController为 UITableView

//UITableViewCell

   //UITableView的每一个单元格是UITableViewCell类的对 UITableViewCell默认提供了3个视图属性:

   UIImageView *imageView  图片视图

   UILabel *textLabel      标题视图

   UILabel *detailTextLabel 副标题视图

//UITableView重用cell的代码流程

   1. 在创建UITableView之后,需要注册一个cell类,当重用池中没有 cell的时候,系统可以自动创建cell。 相关方法:    - (void)registerClass:(Class)cellClass forCellReuseIdentifier: (NSString *)identifier;    2.系统提供了一个获取重⽤用池中cell的⽅方法(需要提供一个重用标 识):    - (UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier;

//UITableViewController

   UITableViewController是继承于UITableViewController中的一个 类,只不过⽐比UITableViewController中多了一个属性tableView。 即:UITableViewController是一个自带table的视图控制器。

//

   一:UITableViewController继承自UITableViewController,自带 一个􏰅ableVie􏰁    二:[self.view]不是UIView而是UITableView    三:datasource和delegate默认都是 self(UITableViewController)    四:开发中只需要建立UITableViewController子类

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容