zoukankan      html  css  js  c++  java
  • CS193p Lecture 11

    UITableView 的 dataSource 和 delegate

    dataSource 是一种协议,由 UITableView 实现,将 Model 的数据给到 UITableView;

    delegate 是关于表格是如何显示的,比如:

     - 如何排布元素;

     - 用哪些视图显示header、footer;

     - 如果用户点击某行,如何响应;

    dataSource

     - numberOfSectionsInTableView

     - numberOfRowsInSection

     - cellForRowAtIndexPath

      create a cell

    1 static NSString *cellIdentifier = @"myCell";
    2 
    3 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    4 
    5 if (cell == nil) {
    6     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    7     
    8     // 配置cell中元素的属性
    9 }

    delegate

     - willDisplayCell

     - didEndDisplayingCell

     - heightForRowAtIndexPath

     - willSelectRowAtIndexPath

     - didSelectRowAtIndexPath

    UITableView Spinner(网络加载中那个转圈圈)

    属性:refreshControl

    beginRefreshing

    endRefreshing

    reloadData

    会重载整个表格

    reloadRowsAtIndexPath

    重载指定行

    iPad的特别之处在于,屏幕大,因此有些手机上需要segue到新页面,在iPad上不用

  • 相关阅读:
    io流(input output)
    Mybatis实例
    框架(mybatis概念及环境搭建
    easyui试做窗口.不完整
    while (rs.next()) 与 if(rs.next())的区别
    json名词解释
    jQuery2
    去除inline-block元素间间距的N种方法
    jQuery的deferred对象详解
    js基础知识集锦
  • 原文地址:https://www.cnblogs.com/mobilefeng/p/4574455.html
Copyright © 2011-2022 走看看