zoukankan      html  css  js  c++  java
  • [iOS基础控件

    A.需要掌握的
    1.基本属性和方法
    • 设置UITableView的dataSource、delegate
    • UITableView多组数据和单组数据的展示
    • UITableViewCell的常见属性
    • UITableView的性能优化(cell的循环利用)
    • 自定义cell
     
    2.UITableView的概念
    UITableView就是表格数据
    UITableView继承自UIScrollView,支持垂直滚动,而且性能好
     
    3.UITableView的两种样式
    • UITableViewStylePlain
    • UITableViewStyleGrouped
     
     
    4.展示数据
    • UITableView需要一个数据源dataSource来显示数据
    • UITableView向数据源查询一共有多少行数据和每一行的显示内容
    • 没有数据源的UITableView只是个空壳
    • 凡是遵守了UITableViewDataSource协议的OC对象,都可以是UITableView的数据源
     
    5.UITableView和数据源
    1 // 数据总组数
    2 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;              // Default is 1 if not implemented
    3  
    4 // 每组数据的行数
    5 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
    6  
    7 // 每一行显示的内容
    8 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
     
    数据源引用:
    1 // 数据源
    2 @property(nonatomic, assign) id<UITableViewDataSource> dataSource;
     
    6.UITableView展示数据的过程
    (1)得到数据的组数
    1 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
     
    (2)得到每组数据的行数
    1 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
     
    (3)得到每行数据的内容
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
     
    7.解析.plist文件,将数据组中的每个Dictionary用Model封装起来存储
     
    8.使用MVC模式
    M: Model
    V: View
    C: Control
     
    9.Cell简介
     
     
    10.UITableViewCell的contentView
     
     
     
    11.UITableViewCell的结构
    Image(68)
     
     
    12.Cell重用原理
         为了应对大量数据的加载和显示,不必创建相同数量的Cell,只需要把当前需要显示的数据加载到cell上就行了。
         原理:滚动列表,移出窗口的UITableViewCell会被放入到一个对象池中,当有数据需要显示的时候,就会从对象池中取出可用的UITableViewCell,然后加载数据显示。
     
    13.自定义的cell重用
         有时候为了特定的需求,需要自定义继承自UITableViewCell的类,可能一个UITableView中存在多种cell,会造成对象池中cell类型的混乱。
         解决:利用UITableViewCell的 NSSting *reuseIdentifier 属性,初始化cell的时候指定reuseIdentifier,这样在对象池取出cell对象的时候要先通过这个字符串标识检查,如果不存在就是使用传入的字符串标识初始化一个cell对象。
     
    14.cell重用代码
     
     
     
     
     
     
  • 相关阅读:
    sql 触发器
    索引使用原则
    索引原理
    索引
    wpf Datagrid 的全选
    WPF ChangePropertyAction中TargetName和TargetObject的区别
    mvvm 模板中事件没有执行的解决方案
    wpf窗口禁止最大化但允许调整大小
    Process打开文件
    installshield 6109错误解决方案
  • 原文地址:https://www.cnblogs.com/hellovoidworld/p/4134084.html
Copyright © 2011-2022 走看看