swift UITabelVIew - 纯代码自定义tabelViewCell
// 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的更多相关文章
- ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布局
本文转自 :http://www.cnblogs.com/wendingding/p/3761730.html ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布 ...
- iOS开发小技巧--纯代码自定义cell
纯代码自定义cell 自定义cell的步骤(每个cell的高度不一样,每个cell里面显示的内容也不一样) 1.新建一个继承自UITableViewCell的子类 2.在initWithStyle:方 ...
- swift 之 纯代码创建 cell
初学swift 但是网上只有很多swift用xib创建的cell,就算是有也不是我想要的.今天自己弄了一个不用xib纯代码写的,来上代码 博客地址: https://github.com/liguol ...
- AJ学IOS(17)UI之纯代码自定义Cell实现新浪微博UI
AJ分享,必须精品 先看效果图 编程思路 代码创建Cell的步骤 1> 创建自定义Cell,继承自UITableViewCell 2> 根据需求,确定控件,并定义属性 3> 用get ...
- swift-UINavigationController纯代码自定义导航控制器及底部工具栏的使用
step1:自定义一个类 NTViewController,该类继承UITabBarController: // // NTViewController.swift // Housekeeper / ...
- 纯代码自定义不等高cell
数据模型.plist解析这里就不过多赘述. 错误思路之一: 通过在heightForRowAtIndexPath:方法中调用cellForRowAtIndexPath:拿到cell,再拿到cell的子 ...
- iOS UITableViewCell UITableVIewController 纯代码开发
iOS UITableViewCell UITableVIewController 纯代码开发 <原创> .纯代码 自定义UITableViewCell 直接上代码 ////// #imp ...
- Cordova - 与iOS原生代码交互2(使用Swift开发Cordova的自定义插件)
在前一篇文章中我介绍了如何通过 js 与原生代码进行交互(Cordova - 与iOS原生代码交互1(通过JS调用Swift方法)),当时是直接对Cordova生成的iOS工程项目进行编辑操作的(添加 ...
- swift 纯代码自定义控件
1.创建自定义控件 import UIKit class CustomView: UIView { var lab:UILabel! var btn:UIButton! /************ 将 ...
随机推荐
- oracle之 RAC 11G ASM下控制文件多路复用
如果数据库仅有一组control file文件,需要添加一组或者多组,保证一组文件损坏或者丢失导致数据库宕机. -- 环境说明SQL> select * from v$version;BANNE ...
- web常用测试点记录
输入框 1.字符型输入框: 单行文本输入框:英文全角.英文半角.数字.空或者空格.特殊字符“~!@#¥%……&*?[]{}”,特别要注意单引号和&符号.如果禁止直接输入特殊字符时,使用 ...
- Oracle中的一些语句
添加字段的语法:alter table tablename add (column datatype [default value][null/not null],….); 修改字段的语法:alter ...
- 在Windows Server 2012启用或关闭Internet Explorer增强的安全配置
在 Windows Sever 2012 中打开 IE 浏览器时,IE10 会出现[已启用 Internet Explorer 增强的安全配置]的提示信息. 在安全性等级中会设置以[高安全性],如果我 ...
- [模板]ST表浅析
ST表,稀疏表,用于求解经典的RMQ问题.即区间最值问题. Problem: 给定n个数和q个询问,对于给定的每个询问有l,r,求区间[l,r]的最大值.. Solution: 主要思想是倍增和区间d ...
- Zookeeper客户端 CuratorFramework使用
CuratorFramework使用 跟着实例学习ZooKeeper的用法: Curator框架应用 ZooKeeper客户端Curator使用一 创建连接
- HTTP Error: 413 Request Entity Too Large的解决
昨天在使用PHP的CURL调用另一个项目的API:A时,出现了HTTP Error: 413 Request Entity Too Large的错误.而调用另一个API:B则没有这个错误. A的API ...
- 修改jvm xms参数
http://hi.baidu.com/200770842223/item/9358aad4f3194e1a20e2501b http://www.cnblogs.com/mingforyou/arc ...
- vs2017运行时修改代码Changes are not allowed while code is running.
vs2017代码运行时不允许进行更改 工具->选项->调试->常规->启用编辑并继续不选择“启用编辑并继续”,这样就可以在调试时修改cs代码了.
- windows7配置Nginx+php+mysql的详细教程
windows7配置Nginx+php+mysql的详细教程 作者:Vincent.李 字体:[增加 减小] 类型:转载 时间:2016-09-04我要评论 这篇文章主要介绍了windows7配置Ng ...