//
//  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. centos下安装docker最新版教程

    1.通过yum安装需要root或者能sudo的权限 yum包更新到最新$ sudo yum update 添加Docker yum源$ sudo tee /etc/yum.repos.d/docker ...

  2. Tomcat 7 的七大新特性(更容易将Tomcat内嵌到应用去中去 )

    Tomcat的7引入了许多新功能,并对现有功能进行了增强.很多文章列出了Tomcat 7的新功能,但大多数并没有详细解释它们,或指出它们的不足,或提供代码示例.本文将明确描述TOMCAT 7中七个最显 ...

  3. php 连接redis

    怎么安装 配置就不说了 最简单的连接方式 <?php //Connecting to Redis server on localhost $redis = new Redis(); $redis ...

  4. Bootstrap-CL:多媒体对象

    ylbtech-Bootstrap-CL:多媒体对象 1.返回顶部 1. Bootstrap 多媒体对象(Media Object) 本章我们将讲解 Bootstrap 中的多媒体对象(Media O ...

  5. ylbtech-Tool:

    ylbtech-Tool: 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   7.返回顶部   8.返回顶部   9.返回顶部   10. ...

  6. 三大运营商2G/3G/4G频率分配和网络制式

    经过二十多年长期的发展,我国的通信业逐渐形成了2G/3G/4G并存的局面,手机通讯信号传输都是通过一定频率传输的,而三大运营商所拥有的频率和网络制式不尽相同,这就造成同一部手机在三大运营商之间可能不通 ...

  7. 5月31日上课笔记-Mysql简介

    一.mysql 配置mysql环境变量 path中添加 D:\Program Files\MySQL\MySQL Server 5.7\bin cmd命令: 登录:mysql -uroot -p 退出 ...

  8. RPM包下载网址

    https://pkgs.org/ (最爱) http://rpm.pbone.net/ http://rpmfind.net/linux/RPM/index.html

  9. solr跨core查询

    参考文档:这里的跨core不使用solrcloud http://wiki.apache.org/solr/CoreAdmin 注意:跨core查询功能相比单core查询,是有限制的   只需要在ur ...

  10. django-model的元类Meta

    Meta类存在model类里面 模型元选项 文档有更多Meta类的配置属性: English:https://docs.djangoproject.com/en/1.11/ref/models/opt ...