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. P4factory <Towards a better behavioral model: bmv2>

    尝试使用bmv2行为模型来跑p4实例. 原文说明: We have released a new version of the behavioral model, written in C++. So ...

  2. Javascript 笔记与总结(2-8)对象2

    注意:标签属性与 DOM 对象属性的对应关系,绝大部分 2 者是相同的,例如 imgobj.src 属性对应 <img src=""> 中的 src 属性 例外:< ...

  3. uitextfield输入字符限制

    -(UITextField*)createField:(NSString*)placeholder andTag:(int)tag andFont:(double)font{ UITextField ...

  4. 如何使用Xcode分析调试在真机运行的UE4 IOS版游戏

    写本文的是因为UE4 官方文档虽然也有,但主要讲的是是用UE4Editor把游戏打成一个IPA包的形式发布的方法 而对于想通过Xcode分析UE4的渲染流程来学习或优化的朋友,那官方文档的资料还是不够 ...

  5. Xamarin 示例Standard Controls报错:xamarin Failed to compile interface file. See Build Output for details

    Standard Controls 示例下载地址: http://developer.xamarin.com/content/StandardControls/ Xamarin官网上的IOS示例“St ...

  6. DateTime Related Functions

    string a = "to_date('" + dtpStart.Value.ToString("yyyy/MM/dd") + "', 'yyyy/ ...

  7. hdf第一周完了,突然时间静止.,醒了就早点去公司上班,再努力一点

    周一要了个任务,做评价完成,分享完成的页面,做到周四发现可能做不出来,找dzy,逻辑比较混乱,想要放弃了,感觉自己非常没用.昨天跟豆聊了一下,否定自己是一点意义也没有的,觉得自己很差劲,无助的感觉跟初 ...

  8. 模板-高精度BigInteger

    #include <bits/stdc++.h> using namespace std; struct BigInteger { static const int BASE = 1000 ...

  9. [转]如何编写和应用Java的自定义异常类

    编写自定义异常类实际上是继承一个API标准异常类,用新定义的异常处理信息覆盖原有信息的过程.常用的编写自定义异常类的模式如下:   public class CustomException exten ...

  10. BLE协议栈及传统蓝牙协议栈对比图

    1. BLE协议栈的层次图如下: 主机控制接口层: 为主机和控制器之间提供标准通信接口 逻辑链路控制及自适应协议层: 为上层提供数据封装服务 安全管理层: 定义配对和密钥分配方式,为协议栈其他层与另一 ...