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上不用

  • 相关阅读:
    VS2010安装笔记
    Blend4中文版中截取图片的方法
    改变窗口的位置 (转载)
    窗口的位置
    windows消息大全
    WM_MOUSELEAVE和WM_MOUSEHOVER使用
    setwindowpos
    无注册表的COM调用
    WM_CLOSE WM_QUIT WM_DESTROY 三者的区别
    WM_MOUSEWHEEL消息
  • 原文地址:https://www.cnblogs.com/mobilefeng/p/4574455.html
Copyright © 2011-2022 走看看