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. [ZZ] RGBM and RGBE encoding for HDR

    Deferred lighting separate lighting rendering and make lighting a completely image-space technique. ...

  2. PHP 错误与异常 笔记与总结(18 )页面重定向实现

    在发生错误时,将用户重定向到另一个页面. <?php header('content-type:text/html; charset=utf-8'); class ExceptionRedire ...

  3. 一些App的User-Agent

    天猫 Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; MI 2C Build/KTU84P) AppleWebKit/537.36 (KHTML, like ...

  4. PureBasic 读取文件中一行的两个数据例子

    , "Test1.txt") ; if the file could be read, we continue... , "Test2.txt") ) = ; ...

  5. Arrays.toString Arrays.asList

    import java.util.Arrays; public class TestCalc{ public static void main(String[] args) { ,,,,,,,}; / ...

  6. Android@Home Apple HomeKit

    Android@Home采用基于IEEE802.15.4标准的低功耗个域网协议的ZigBee技术,其是低功耗.低成本及低延迟.标准功率下可满足100米范围内的信号覆盖,并拥有三级安全模式,防止非法获取 ...

  7. 将所有程序设置XML集中到一个单独XML配置文件的方法:使用appSettings元素的configSource元素

    在.NET程序中,程序的配置文件默认都会放在程序根目录下的web.config(网站程序)或App.config(控制台等程序),在该配置文件中可以定义若干程序配置信息. 在此以网站程序为例,首先将下 ...

  8. 用户登录验证例题用的ajax

    1.登录页面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. ...

  9. pro5

    1.本次课学到的知识点 (1)循环结构的概念 在我们需要重复进行某个步骤是就需要运用到循环结构. (2)三种循环语句 for,while,do-while是三种常用的循环语句,其中while的适用范围 ...

  10. 蓝牙—服务发现协议(SDP)

    服务搜索协议(SDP)提供了应用发现可用服务以及确定可用服务特点的方法.SDP发现协议提供下面的能力 <1>为客户提供搜索所需要服务的能力. <2>允许基于服务类型搜索服务 & ...