//
//  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. cas sso ajax的jsonp实现方案总结(新浪微薄、淘宝案例分析)

    Cas自定义登录页面Ajax实现:http://cydiay.iteye.com/blog/1738713 CAS 之 跨域 Ajax 登录实践:http://denger.iteye.com/blo ...

  2. SQL优化之索引分析

    索引的重要性 数据库性能优化中索引绝对是一个重量级的因素,可以说,索引使用不当,其它优化措施将毫无意义. 聚簇索引(Clustered Index)和非聚簇索引 (Non- Clustered Ind ...

  3. Mysql8.0 Public Key Retrieval is not allow错误的解决办法

    在使用Mysql 8.0时重启后启动项目的事后会报错com.mysql.jdbc.exceptions.jdbc4.MysqlNonTransientConnectionException: Publ ...

  4. mac php apache mysql 集成环境 的软件

    http://xclient.info/s/mamp-pro.html?t=4e60e3c234937f46b33e6b15eeafeb5ee326afa4 MAMP Pro 5.1 集成web服务器 ...

  5. ddt数据驱动

    数据驱动原理 1.测试数据为多个字典的list类型 2.测试类前加修饰@ddt.ddt 3.case前加修饰@ddt.data() 4.运行后用例会自动加载成三个单独的用例 5.测试结果: Testi ...

  6. Codeforces Round #456 B题

    一.题意 给你一个n和一个k,让你从[1, n]区间内选k个数,这k个数异或和最大. 二.思路 我一开始看到这种题,不自觉地就想到,莫非又要搞很复杂的线段树.主席树?貌似还有些难搞啊.然而事实是:Co ...

  7. python xlwt操作excel

  8. Javascript typeof 用法

    在js里用到数组,比如 多个名字相同的input, 若是动态生成的, 提交时就需要判断其是否是数组. if(document.mylist.length != "undefined" ...

  9. eclipse Android 开发基础 Activity 窗体 界面

    eclipse Android 开发基础 新建工程 新建布局layout,new Android Activity就相当于窗体Form. 新建Activity自动生成src下同名的java代码. pu ...

  10. Python Geoip 获取IP地址经度、纬度

    简介: 除了一些免费的 API 接口,例如 http://ipinfo.io/223.155.166.172 可以得到一些信息外,还可以通过 python-geoip 库来解决这个问题. shell ...