zoukankan      html  css  js  c++  java
  • Swift

    通过使用静态单元格的列表,我们可以很方便的进行页面布局。下面通过一个“添加任务页面”来进行演示。

    效果图如下:


    实现步骤:
    1,在storyboard中拖入一个TableViewController,同时创建一个对应的类(MyTabelViewController.swift)进行绑定。
    2,选择表格,在属性面板中设置Content为Static Cells,Sections设置为2


    3,选中第1个Sections,将Rows设置为1,并拖入一个TextFiled到单元格中


    4,选中第2个Sections,将Rows设置为2,分别给两个单元格拖入对应的Label和Switch等控件

     
    5,MyTabelViewController.swift
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    class MyTableViewController: UITableViewController {
     
        override func viewDidLoad() {
            super.viewDidLoad()
           
            self.title = "添加任务"
            //去除尾部多余的空行
            self.tableView.tableFooterView = UIView(frame:CGRectZero)
        }
     
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
        }
     
        override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
            return 2
        }
     
        override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
            if section == 0 {
                return 1
            }else{
                return 2
            }      
        }
     
    }
  • 相关阅读:
    一剑走四方华山论剑
    本命年之冬去春来
    time of our lives从世界杯主题曲看厚脸皮的德国人:)
    我回来啦:)
    PHP undefined index的几种解决方法
    Nginx 502 Bad Gateway错误及解决方案收集
    Nginx Cache的5种方案
    PHP中ts和nts版本 vc6和vc9编译版本的区别
    Linux 查看连接数命令
    Nginx Proxy 作图片缓存配置文件
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/4841085.html
Copyright © 2011-2022 走看看