swift 4.0 创建tableview 自定义cell
//
// ViewController.swift
// AlamofileDemo
//
// Created by Alex on 2019/3/5.
// Copyright © 2019 AlexanderYeah. All rights reserved.
//import UIKit
import Alamofire// 遵守协议方法
class ViewController: UIViewController,UITableViewDataSource,UITableViewDelegate {var tableview:UITableView = UITableView();let Screen_Width = UIScreen.main.bounds.size.width;let Screen_Height = UIScreen.main.bounds.size.height;override func viewDidLoad() {super.viewDidLoad()// Do any additional setup after loading the view, typically from a nib.tableview = UITableView(frame: CGRect(x: 0, y: 100, width: Screen_Width, height: Screen_Height - 100));tableview.delegate = self as UITableViewDelegate;tableview.dataSource = self as UITableViewDataSource;self.view.addSubview(tableview);// 自定义celltableview.register(UINib.init(nibName: "TableViewCell", bundle: nil), forCellReuseIdentifier:"TableViewCell");}// UITableViewDataSource 数据源func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {return 150;}func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {var cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell" ) as? TableViewCell;if cell == nil {cell = TableViewCell(style: .default, reuseIdentifier: "TableViewCell");}cell?.selectionStyle = .none;cell?.titleLbl?.text = "123456";return cell!;}func tableView(_ tableView: UITableView,numberOfRowsInSection section: Int) -> Int{return 5;}}
swift 4.0 创建tableview 自定义cell相关推荐
- 静态tableview组背景色的更改及自定义cell的两种方式
为什么80%的码农都做不了架构师?>>> 1 修改默认的静态tableview背景色的方法: UITableView *orderTableView = [[UITableVi ...
- UIBezierPath和CAShapeLayer创建不规则View(Swift 3.0)
最近一个朋友在做图片处理的 App,想要实现类似 MOLDIV App 拼图的UI效果(如何创建不规则的 view),就问我有什么想法.我首先想到的就是 UIBezierPath+CAShapeLay ...
- barbuttonitem 文字换行_IOS TableView的Cell高度自适应,UILabel自动换行适应
ios tableView那些事 (八) tableview的插入移动.self.tableview.editinganimated:YES];- (BOOL)tableView:(UITableVi ...
- iOS 自定义Cell按钮的点击代理事件
在实际开发工作中,我们经常会在自定义的Cell中布局一些按钮,并且很多时候我们会在点击这个按钮的时候使我们的UItableviewController跳转到下一界面,有的可能还要传值.那么如何使我们的 ...
- 自定义cell的左侧滑动
效果如上图,中间那个白线是一个UIview. 如果不添加中间那根白线,用系统的方法就可以实现,方法如下 1 -(NSArray<UITableViewRowAction*>*)tableV ...
- (素材源码)猫猫学IOS(十七)UI之纯代码自定义Cell实现新浪微博UI
猫猫分享,必须精品 素材代码地址:http://download.csdn.net/detail/u013357243/8580249 原文地址:http://blog.csdn.net/u01335 ...
- iOS开发UI篇—以微博界面为例使用纯代码自定义cell程序编码全过程(三·完结)...
一.需要改进的地方 还需改进的地方:cell的高度需要根据每条微博的数据进行动态设置. 设置cell的高度可以有两种方式,一种是通过rowheight属性来进行设置,一种是通过代理来进行设置.通过属性 ...
- 猫猫学IOS(十七)UI之纯代码自定义Cell实现新浪微博UI
猫猫分享,必须精品 素材代码地址:http://blog.csdn.net/u013357243/article/details/44976175 原文地址:http://blog.csdn.net/ ...
- iOS开发之高级视图—— UITableView(四)自定义Cell
当我们使用UITableView的时候,经常需要自定义Cell,这个例子展示了一个简单的自定义的Cell. HeroViewCell.h // // HeroViewCell.h // ExtendC ...
最新文章
- NASM、MASM浅谈
- 中国男人何时回归家庭?(转)
- 硬盘显示容量和实际容量不符合_买移动固态硬盘纠结大半天?花2分钟看完这篇,购买时不再被坑...
- Android中使用Thread线程出现的问题
- 数据库基础(3)函数依赖-平凡依赖,完全依赖,部分依赖,传递依赖
- 4线-2线优先编码器
- docker本地仓库(本地镜像仓库)环境搭建
- 国外优秀JAVA技术网站推荐
- Amine-PEG-Pyrene,芘丁酸聚乙二醇氨基,Pyrene-PEG-NH2
- 精确光源 Punctual Light Source
- K8s 之 ReadinessProbe(就绪探针)使用的迷惑
- 总体标准差、样本标准差、标准误差
- HTTP请求返回状态码详解
- 计算机基础_001_栈是什么
- layui实现导出全部数据Excel
- 美国泛达网络:新一代通用型数据中心机柜
- rust2020几月上架ps4_《腐蚀Rust》将于上架PS4,老玩家:爆肝警告,入坑需谨慎
- PostgreSQL 12 `GRANT` 命令
- 盘点不常用却很有用的代码 ,欢迎大家留言
- 防止tweak依附,App有高招;破解App保护,tweak留一手