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! /************ 将 ...
随机推荐
- Asp.net MVC Comet 推送
一.简介 在Asp.net MVC实现的Comet推送的原理很简单. 服务器端:接收到服务器发送的AJAX请求,服务器端并不返回,而是将其Hold住,待到有东西要通知客户端时,才将这个请求返回. 客户 ...
- 【python】常用的日期和时间操作
#-*- coding: utf-8 -*- import datetime #给定日期向后N天的日期 def dateadd_day(days): d1 = datetime.datetime.no ...
- beautifulsoup 基本语法
案例一: #coding=utf-8import jsonimport requestsfrom bs4 import BeautifulSoupurl = 'http://www.itest.inf ...
- 通过BeanFactoryPostProcessor来获取bean
一.现在我们很多时候都在spring的容器中,进行bean的提取和操作,但是配置里面首先需要扫描相应的包来实现相关bean的注入 但是问题来了.如果我们在另外一个线程需要用的时候,并且没有配置扫描该类 ...
- linux shell 修改文本 sed
linux shell 修改文本echo [root@DSI tmp]# echo 'yhqt1 test1' > test1.txt [root@DSI tmp]# cat test1.txt ...
- 20181123_控制反转(IOC)和依赖注入(DI)
一. 控制反转和依赖注入: 控制反转的前提, 是依赖倒置原则, 系统架构时,高层模块不应该依赖于低层模块,二者通过抽象来依赖 (依赖抽象,而不是细节) 如果要想做到控制反转(IOC), 就必须要使 ...
- 2018 Multi-University Training Contest 6-oval-and-rectangle(hdu 6362)-题解
一.题意 求椭圆内接矩形周长的期望. 二.推导过程 已知$c$,容易得出矩形弦长$d=4a\sqrt{1-\frac{c^2}{b^2}}$ 接下来,矩形周长$p=4c+d=4c+4a\sqrt{1- ...
- Python——截取web网页长图
# -*- coding: utf8 -*-import timeimport xlrdfrom selenium import webdriver def read_excel(filename): ...
- php时间轴函数,很不错,记下了
function TranTime($time) { //$time = strtotime($time); $nowTime = time (); $message = ''; if(empty($ ...
- ES6系列_7之箭头函数和扩展
1.默认值 在ES6中给我们增加了默认值的操作相关代码如下: function add(a,b=1){ return a+b; } console.log(add(1)); 可以看到现在只需要传递一个 ...