//
//  CustomTableViewCell.swift
//  tab
//
//  Created by su on 15/12/7.
//  Copyright © 2015年 tian. All rights reserved.
//

import UIKit

class CustomTableViewCell: UITableViewCell {
    var nameLabe: UILabel!
    var typeLabel: UILabel!
   
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.seupUI()
    }

required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
   
    func seupUI() {
        nameLabe = UILabel(frame: CGRect(x: 10, y: 10, width: 20, height: 20))
        nameLabe.backgroundColor = Tools().RGB(r: 122, g: 111, b: 123)
        self.addSubview(nameLabe)
        typeLabel = UILabel(frame: CGRect(x: 10, y: 40, width: 20, height: 20))
        typeLabel.backgroundColor = UIColor.blackColor()
        self.addSubview(typeLabel)
    }
   
//    func initWith(restName: String, restLocation: String){
//        nameLabe.text = restName
//        typeLabel.text = restLocation
//     
//    }
   
    override func awakeFromNib() {
        super.awakeFromNib()
       
        // Initialization code
    }
//   override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
//        super.init(style: UITableViewCellStyle, reuseIdentifier: String?)
//    }
   
    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

// Configure the view for the selected state
    }

}
 

//

//  ThreeViewController.swift

//  tab

//

//  Created by su on 15/12/7.

//  Copyright © 2015年 tian. All rights reserved.

//

import UIKit

class ThreeViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

var tableView = UITableView()

override func viewDidLoad() {

super.viewDidLoad()

self.view.backgroundColor =  UIColor.grayColor()

self.navigationItem.title = "cc"

let right = UIBarButtonItem(title: "alertView", style: UIBarButtonItemStyle.Plain, target: self, action: "go:")

self.navigationItem.rightBarButtonItem = right

tableView = UITableView(frame: self.view.bounds)

tableView.delegate = self

tableView.dataSource = self

tableView.registerClass(CustomTableViewCell.self, forCellReuseIdentifier: "cell")

self.view.addSubview(tableView)

}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

return 5

}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let identifier = "cell"

var cell = tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath) as? CustomTableViewCell

if cell == nil {

cell = CustomTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: identifier)

}

cell?.nameLabe.text = "123434555677yhgfcdxs"

cell?.typeLabel.text = "gggggggggggggggggggg"

return cell!

}

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {

return 80

}

func go(right:UIBarButtonItem){

let pushVC = PushViewController()

self.navigationController?.pushViewController(pushVC, animated: true)

}

override func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

// Dispose of any resources that can be recreated.

}

/*

// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

// Get the new view controller using segue.destinationViewController.

// Pass the selected object to the new view controller.

}

*/

}

swift UITabelVIew - 纯代码自定义tabelViewCell的更多相关文章

  1. ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布局

    本文转自 :http://www.cnblogs.com/wendingding/p/3761730.html ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布 ...

  2. iOS开发小技巧--纯代码自定义cell

    纯代码自定义cell 自定义cell的步骤(每个cell的高度不一样,每个cell里面显示的内容也不一样) 1.新建一个继承自UITableViewCell的子类 2.在initWithStyle:方 ...

  3. swift 之 纯代码创建 cell

    初学swift 但是网上只有很多swift用xib创建的cell,就算是有也不是我想要的.今天自己弄了一个不用xib纯代码写的,来上代码 博客地址: https://github.com/liguol ...

  4. AJ学IOS(17)UI之纯代码自定义Cell实现新浪微博UI

    AJ分享,必须精品 先看效果图 编程思路 代码创建Cell的步骤 1> 创建自定义Cell,继承自UITableViewCell 2> 根据需求,确定控件,并定义属性 3> 用get ...

  5. swift-UINavigationController纯代码自定义导航控制器及底部工具栏的使用

    step1:自定义一个类  NTViewController,该类继承UITabBarController: // // NTViewController.swift // Housekeeper / ...

  6. 纯代码自定义不等高cell

    数据模型.plist解析这里就不过多赘述. 错误思路之一: 通过在heightForRowAtIndexPath:方法中调用cellForRowAtIndexPath:拿到cell,再拿到cell的子 ...

  7. iOS UITableViewCell UITableVIewController 纯代码开发

    iOS UITableViewCell UITableVIewController 纯代码开发 <原创> .纯代码 自定义UITableViewCell 直接上代码 ////// #imp ...

  8. Cordova - 与iOS原生代码交互2(使用Swift开发Cordova的自定义插件)

    在前一篇文章中我介绍了如何通过 js 与原生代码进行交互(Cordova - 与iOS原生代码交互1(通过JS调用Swift方法)),当时是直接对Cordova生成的iOS工程项目进行编辑操作的(添加 ...

  9. swift 纯代码自定义控件

    1.创建自定义控件 import UIKit class CustomView: UIView { var lab:UILabel! var btn:UIButton! /************ 将 ...

随机推荐

  1. PhpStorm 10.0.3 下载安装与汉化

    https://www.7down.com/soft/229568.html 2JA97R55MG-eyJsaWNlbnNlSWQiOiIySkE5N1I1NU1HIiwibGljZW5zZWVOYW ...

  2. SQL Server中的事务与其隔离级别之脏读, 未提交读,不可重复读和幻读

    原本打算写有关 SSIS Package 中的事务控制过程的,但是发现很多基本的概念还是需要有 SQL Server 事务和事务的隔离级别做基础铺垫.所以花了点时间,把 SQL Server 数据库中 ...

  3. 智能家居入门DIY——【三、GP2Y10之颗粒物传感器】

    这个传感器接线算比较简单的,程序也不麻烦.不过这东西是颗粒物传感器吧,不是神马PM2.5(总悬浮颗粒物),不是神马PM10(可吸入颗粒物).插个螺丝刀进去度数也是变的,不是说的很清楚原理是反光嘛……… ...

  4. linux编程基本

    库的使用头文件:.h 里面的函数及变量的声明 比如#include <stdio.h> ,Linux下默认头文件的搜索路径 系统定义的头文件: /usr/include /usr/loca ...

  5. CSS: body{font-size: 62.5%;}设置原因

    参考博客:http://www.cnblogs.com/daxiong/articles/2772276.html 在网页设计中我们经常看见body{font-size: 62.5%;}这样的设置,为 ...

  6. 1711 Number Sequence(kmp)

    Number Sequence Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) To ...

  7. Oracle中 HWM与数据库性能的探讨

    链接:http://www.eygle.com/archives/2011/11/oracle_hwm_tuning.html 本文讨论的是oracle中关于table的HWM的内容,主要包括这样几个 ...

  8. 新建网站与新建Asp.Net Web 应用程序的区别

    .net网站和应用程序区别,网站是动态执行的不用编译,他只依赖于自己的文档本身,甚至你用aspx里直接写jsp代码都可以,其实网站可以说只是在.net平台中打开的文档,相当于最初的记事本编码,他并不需 ...

  9. C关系运算结果及逻辑运算结果保存

    http://service.exmail.qq.com/

  10. leetcode507

    public class Solution { public bool CheckPerfectNumber(int num) { ) { return false; } ; ; i <= nu ...