import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
// Override point for customization after application launch.
self.window!.backgroundColor = UIColor.whiteColor() let navigation = UINavigationController(rootViewController: RootViewController())
self.window?.rootViewController = navigation self.window!.makeKeyAndVisible()
return true
} }
import UIKit

class RootViewController: UIViewController {

    override func loadView() {
super.loadView()
//初始化UITableView
let tableView = UITableView()
tableView.frame = UIScreen.mainScreen().bounds
tableView.dataSource = self
tableView.delegate = self
self.view.addSubview(tableView)
}
//懒加载数据
lazy var datas:[String] = {
return ["是雨是泪","分分钟需要你","伤心太平洋","曾经最痛","飘雪"]
}() override func viewDidLoad() {
super.viewDidLoad()
self.title = "UITableView的基本用法"
}
} extension RootViewController:UITableViewDelegate,UITableViewDataSource
{
//区的个数
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return
}
//在相应区中cell的个数
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return datas.count
}
// cell的高度
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return
} func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//在重用机制里取出cell
var cell = tableView.dequeueReusableCellWithIdentifier("cell")
//如果cell为空则创建
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell")
}
//设置数据
cell?.textLabel?.text = datas[indexPath.row]
return cell!
} }

SWIFT UITableView的基本用法的更多相关文章

  1. Swift - UITableView展开缩放动画

    Swift - UITableView展开缩放动画 效果 源码 https://github.com/YouXianMing/Swift-Animations // // HeaderViewTapA ...

  2. Swift - UITableView状态切换效果

    Swift - UITableView状态切换效果 效果 源码 https://github.com/YouXianMing/Swift-Animations // // TableViewTapAn ...

  3. Swift - UITableView的用法

    因为倾向于纯代码编码,所以不太喜欢可视化编程,不过也略有研究,所以项目里面的所有界面效果,全部都是纯代码编写! 终于到了重中之重的tableview的学习了,自我学习ios编程以来,工作中用得最多的就 ...

  4. IOS SWIFT UITableView 实现简单微博列表

    // // Weibo.swift // UITableViewCellExample // // Created by XUYAN on 15/8/15. // Copyright (c) 2015 ...

  5. Swift枚举的全用法

    鉴于昨天开会部门会议讨论的时候,发现有些朋友对枚举的用法还是存在一些疑问,所以就写下这个文章,介绍下Swift下的枚举的用法. 基本的枚举类型 来,二话不说,我们先贴一个最基本的枚举: enum Mo ...

  6. Swift - UITableView里的cell底部分割线左侧靠边

    override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, ...

  7. IOS第七天(1:UiTableView 的基本用法)

    ***表格控件 #import "HMViewController.h" @interface HMViewController () <UITableViewDataSou ...

  8. 【iOS】swift 排序Sort函数用法(包含NSDictionary排序)

    用了几分钟做的简单翻译 一个例子 直接贴代码,不过多解释 //这是我们的model class imageFile { var fileName = String() var fileID = Int ...

  9. ios初识UITableView及简单用法二(模型数据)

    // // ViewController.m // ZQRTableViewTest // // Created by zzqqrr on 17/8/24. // Copyright (c) 2017 ...

随机推荐

  1. ASP.NET MVC4系列验证机制、伙伴类共享源数据信息(数据注解和验证)

    一,mvc前后台验证 自定义属性标签MyRegularExpression using System; using System.Collections.Generic; using System.C ...

  2. PHP 设计模式 笔记与总结(4)PHP 链式操作的实现

    PHP 链式操作的实现 $db->where()->limit()->order(); 在 Common 下创建 Database.php. 链式操作最核心的地方在于:在方法的最后 ...

  3. NFS文件系统

    一.nfs服务端CentOS6安装nfs-utils和rpcbind两个软件包yum install nfs-utils rpcbind编辑/etc/exports加入:/nfsdir 192.168 ...

  4. Nginx_Lua

    http://www.ttlsa.com/nginx/nginx-lua/ 1.1. 介绍ngx_lua – 把lua语言嵌入nginx中,使其支持lua来快速开发基于nginx下的业务逻辑该模块不在 ...

  5. PLSQL 设置

    设置plsql使用特定的oracle数据库客户端来与数据库进行交互

  6. CSS :before和:after (转)

    前几天的晚上较全面的去看了下css的一些文档和资料,大部分的样式运用都没什么大问题了,只是有些许较陌生,但是也知道他们的存在和实现的是什么样式.今天主要想在这篇学习笔记中写的也不多,主要是针对:bef ...

  7. 使用SVN提示“工作副本已经锁定”的解决办法

    更新或者提交前执行一下clean up.如果在当前目录执行该命令后,仍然提示锁定,就到上一层目录再执行下...

  8. 备份mysql

    #!/bin/bash # 要备份的数据库名,多个数据库用空格分开USER=rootPASSWORD=rootdatabases=("shopnc") # 备份文件要保存的目录ba ...

  9. Redis学习笔记--五种数据类型的使用场景

    String 1.String 常用命令: 除了get.set.incr.decr mget等操作外,Redis还提供了下面一些操作: 获取字符串长度 往字符串append内容 设置和获取字符串的某一 ...

  10. Hue协作框架

    http://archive.cloudera.com/cdh5/cdh/5/hue-3.7.0-cdh5.3.6/manual.html 一:框架 1.支持的框架 ->job ->yar ...