//
//  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. 浅析网站建设的PHP,JAVA语言分析

    编程绝对是一件不轻松的活儿.随着电子商务在国内成功的推广,京东.苏宁等大型B2C综合网上商城的成功运营,一批批以产业分类的独立网店也如火如荼发展起来.伴随着这股热潮,网店系统等相关衍生开店平台行业也出 ...

  2. npm查看全局安装过的包

    在使用node的时候,用npm安装了很多软件,过一段时间没有使用就会忘记,怎么查看自己全局安装过的包,用命令 npm list -g --depth 0 在百度里搜不到结果的,我在google里老外的 ...

  3. 工欲善其事必先利其器系列之:更换Visual Studio主题.

    前言:如果你厌烦的vs2010的蓝色风格主题,可以使用Visual Studio Color Theme Editor这款插件来改变主题风格,不过我还是喜欢METRO风格. 效果图预览: Windwo ...

  4. php 的两个扩展 memcache 和 memcachd

    今天绕了很大弯子, 因为自己写的php的memcache类. 于是出现了下面问题 在本地测试好好的, 线上就出了问题 原因是线上使用的是memcache, 我本地使用的是memcached 区别参考网 ...

  5. Spring中使用JDBC

    Spring中的数据库异常体系 使用JDBC(不使用Spring)的时候,我们需要强制捕获SQLException,否则无法使用JDBC处理任何事情.SQLException表示尝试访问数据库的时候出 ...

  6. 常见的JS和CSS问题

    事件冒泡 DOM的事件冒泡机制和WPF很相似,DOM事件机制包含冒泡和捕获两种,按照topmost element->innermost element方向传递事件被称为捕获方式,而从inner ...

  7. 并发包学习(一)-Atomic包小记

    此篇是J.U.C学习的第一篇Atomic包相关的内容,希望此篇总结能对自己的基础有所提升.本文总结来源自<Java并发编程的艺术>第七章并配以自己的实践理解.如有错误还请指正. 一.案例分 ...

  8. delphi XE8 NetHTTPRequest NetHTTPClient

    delphi xe8 推出2个新http控件,NetHTTPRequest.NetHTTPClient 可以调用ASP.Net 一般应用程序获取网页数据,用旧的控件idhttp控件也可以,推荐用新的这 ...

  9. Discuz 任务、道具、任务和验证类插件制作

    一.广告类脚本位置:source/class/adv/adv_name.php语言包位置:source/language/adv/lang_name.php <?php class adv_na ...

  10. MyBatis 查询缓存

    增删改操作对一级缓存的影响:增删改操作都会清空一级缓存,无论是否提交