用代码写静态的cell

示例狂
• 阅读 326

iOSExamples-StaticCells
This project is an example for implementing a UITableView that has static cells. This pattern is often used on options pages or for creating/editing model objects.

The gist is that you can create a static number of cells and store them as variables. You can then use the tableView: cellForRowAtIndexPath method to retrive the appropriate UITableViewCell variable.

// Return the row for the corresponding section and row

  • (UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    switch(indexPath.section)
    {

      case 0:
      switch(indexPath.row)
      {
          case 0: return self.firstNameCell;  // section 0, row 0 is the first name
          case 1: return self.lastNameCell;   // section 0, row 1 is the last name
      }
      case 1:
      switch(indexPath.row)
      {
          case 0: return self.shareCell;      // section 1, row 0 is the share option
      }

    }
    return nil;
    }
    // Return the row for the corresponding section and row
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    switch(indexPath.section) {
    case 0:

      switch(indexPath.row) {
      case 0: return self.firstNameCell   // section 0, row 0 is the first name
      case 1: return self.lastNameCell    // section 0, row 1 is the last name
      default: fatalError("Unknown row in section 0")
      }

    case 1:

      switch(indexPath.row) {
      case 0: return self.shareCell       // section 1, row 0 is the share option
      default: fatalError("Unknown row in section 1")
      }

    default: fatalError("Unknown section")
    }
    }
    This example is implemented in both Objective-C and Swift. You can open the workspace to view both projects simultaneously.

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
1年前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
4年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Wesley13 Wesley13
3年前
java中比较两个时间的差值
项目背景1.某篇文稿的发布时间是publishDate,例如:2020072118:00:41。2.现要求判断该篇文稿的发布时间是否在近30天之内。publicstaticlongdayDiff(DatecurrentDate,DatepublishDate){LongcurrentTimecurrentDat
CuterCorley CuterCorley
4年前
C语言基础习题50例(九)41-45
习题41学习static定义静态变量的用法。实现思路:用static声明和未用static声明变量进行对比,即可得出static的作用。代码如下:cinclude<stdio.hintmain(){voidfunc();inti;for(i0;i<10;i){func();}return
Stella981 Stella981
3年前
KaliTools说明书+BurpSuit实战指南+SQL注入知识库+国外渗透报告
!(https://oscimg.oschina.net/oscnet/d1c876a571bb41a7942dd9752f68632e.gif"15254461546.gif")0X00KaliLinux Tools中文说明书!(https://oscimg.oschina.net/oscnet/
Stella981 Stella981
3年前
JS 苹果手机日期显示NaN问题
问题描述newDate("2019122910:30:00")在IOS下显示为NaN原因分析带的日期IOS下存在兼容问题解决方法字符串替换letdateStr"2019122910:30:00";datedateStr.repl
Wesley13 Wesley13
3年前
MySQL总结(十一)子查询
!(https://oscimg.oschina.net/oscnet/upa344f41e81d3568e3310b5da00c57ced8ea.png)子查询1\.什么是子查询需求:查询开发部中有哪些员工selectfromemp;通
Python进阶者 Python进阶者
1年前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这
美凌格栋栋酱 美凌格栋栋酱
5个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(