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. php扩展redis,编译安装redis服务

    首先安装redis扩展 https://github.com/phpredis/phpredis 下载http://redis.io/download 服务软件 cd到软件存放目录unzip phpr ...

  2. SwfUpload学习记录

    参考资料: SWFUpload 2.5.0版 官方说明文档 中文翻译版 了解SWFUpload 多文件上传配置详解 WEB版一次选择多个文件进行批量上传(swfupload)的解决方案 jQuery轻 ...

  3. 【转】Java跨平台原理

    原文地址:http://www.cnblogs.com/gw811/archive/2012/09/09/2677386.html 1.是么是平台 Java是可以跨平台的编程语言,那我们首先得知道什么 ...

  4. jQuery中添加/改变/移除改变CSS样式例子

    在jquery中对于div样式操作我们会使用到CSS() removeClass() addClass()方法来操作了,下面我们就整理了几个例子大家一起来看看吧.     CSS()方法改变CSS样式 ...

  5. Javascript 笔记与总结(2-9)获取运行时的 style 对象

    获取内存中(正在渲染)的 style 的值(非内联 style,obj.style 只能获得内联 style 的值),可以用 obj.currentStyle(低版本 IE 和 Opera 支持)和 ...

  6. Levenshtein distance

    https://en.wikipedia.org/wiki/Levenshtein_distance 验证码识别 图片中的二维码截取

  7. PHP正则表达式;数组:for()遍历、 foreach ()遍历、each()list()组合遍历;指针遍历

    正则表达式:    1.定界符号        任何字符,一般用  //    2. 模式修正符i        写在定界符外面后面,可不区分大小写    3.preg_replace($reg,&q ...

  8. 蓝牙4.0的LM层说明

    1.概念 The Link Manager Protocol (LMP) is used to control and negotiate all aspects of the operation o ...

  9. URL编码数据转换为JSON数据

    NSString *urlString; urlString=[self    URLDecodedString:urlString]; -(NSString *)URLDecodedString:( ...

  10. Servlet Threading Model

    Servlet Threading Model The scalability issues of Java servlets are caused mainly by the server thre ...