zoukankan      html  css  js  c++  java
  • UITableView的简单使用

    UITableView在ios开发中,很重要,它的实现只要有两个部分组成。第一:数据源方法   第二:代理方法。

    下面我们就详细的介绍一些数据源和代理方法的使用:

    1.数据源方法->常用的5个数据源方法

      在初始化后的tableView中,有两个数据源方法必须实现。

      - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;//返回表格中有多少行

      - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;//返回每一行显示的内容

      剩下的方法都是可选的

      - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;              // 返回在表格中将要显示有多少组

      - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;    // 返回头部标题

      - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;  //返回尾部标题

    2.代理方法 ->常用的

      - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; //选中这一行就会调用该方法

    tableview的代理方法太多了,其它的暂时还每研究,晚些会更新的。

  • 相关阅读:
    从屏幕截取一块区域,将其赋给imageView
    oc 中随机数的用法(arc4random() 、random()、CCRANDOM_0_1()
    UIPopoverController
    IOS-- UIView中的坐标转换
    TCP、UDP的区别
    TCP/IP协议简单介绍
    NSTimer类的使用
    UI基础-网络编程
    IOS面试中的一些问题
    iOS开发UI篇—UITabBarController简单介绍
  • 原文地址:https://www.cnblogs.com/yinqiang/p/3450402.html
Copyright © 2011-2022 走看看