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! /************ 将 ...
随机推荐
- erlang和ruby互相调用
erlang调用ruby https://github.com/mojombo/erlectricity ruby调用erlang https://github.com/davebryson/rint ...
- emacs之配置php
php-setting.el (require 'php-mode) 以后丰富
- Java 正则表达式详细实例解析
案例1:判断字符串是否是abc package Regex; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * ...
- php时间轴函数,很不错,记下了
function TranTime($time) { //$time = strtotime($time); $nowTime = time (); $message = ''; if(empty($ ...
- 使用TensorFlow识别照片中的物体
1.环境ubuntu14.04.5 安装TensorFlow 官方文档:https://www.tensorflow.org/install/install_linux sudo pip instal ...
- python 2.7中安装mysql
在python中进行安装mysql模块,但是怎么都不能导入mysql模块,出错如下所示: [root@python ~]# python Python 2.7.11 (default, Apr 5 2 ...
- 将com口2号引脚、3号引脚引出来,两个引脚对接会出发中断
思路:让程序一直不停的发数据,再设一个及接收事件,接通(短路)后触发. 灵感文章: 方案一: 去AQ解决话务台问题,下了车就牛不停蹄的去买了串口挡板,db9 female接口,根据2-3.3-2.5 ...
- 当前触发事件的两种方式(onclick) 和 ('id') 获取
1. <input type='text' onclick = 'Clickon(this)'> <script> function Clickon(num){ num.sty ...
- lda spark 代码官方文档
http://spark.apache.org/docs/1.6.1/mllib-clustering.html#latent-dirichlet-allocation-lda http://spar ...
- 46. Permutations (Back-Track,Sort)
Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the follow ...