//
//  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相关推荐

  1. 静态tableview组背景色的更改及自定义cell的两种方式

    为什么80%的码农都做不了架构师?>>>    1 修改默认的静态tableview背景色的方法: UITableView *orderTableView = [[UITableVi ...

  2. UIBezierPath和CAShapeLayer创建不规则View(Swift 3.0)

    最近一个朋友在做图片处理的 App,想要实现类似 MOLDIV App 拼图的UI效果(如何创建不规则的 view),就问我有什么想法.我首先想到的就是 UIBezierPath+CAShapeLay ...

  3. barbuttonitem 文字换行_IOS TableView的Cell高度自适应,UILabel自动换行适应

    ios tableView那些事 (八) tableview的插入移动.self.tableview.editinganimated:YES];- (BOOL)tableView:(UITableVi ...

  4. iOS 自定义Cell按钮的点击代理事件

    在实际开发工作中,我们经常会在自定义的Cell中布局一些按钮,并且很多时候我们会在点击这个按钮的时候使我们的UItableviewController跳转到下一界面,有的可能还要传值.那么如何使我们的 ...

  5. 自定义cell的左侧滑动

    效果如上图,中间那个白线是一个UIview. 如果不添加中间那根白线,用系统的方法就可以实现,方法如下 1 -(NSArray<UITableViewRowAction*>*)tableV ...

  6. (素材源码)猫猫学IOS(十七)UI之纯代码自定义Cell实现新浪微博UI

    猫猫分享,必须精品 素材代码地址:http://download.csdn.net/detail/u013357243/8580249 原文地址:http://blog.csdn.net/u01335 ...

  7. iOS开发UI篇—以微博界面为例使用纯代码自定义cell程序编码全过程(三·完结)...

    一.需要改进的地方 还需改进的地方:cell的高度需要根据每条微博的数据进行动态设置. 设置cell的高度可以有两种方式,一种是通过rowheight属性来进行设置,一种是通过代理来进行设置.通过属性 ...

  8. 猫猫学IOS(十七)UI之纯代码自定义Cell实现新浪微博UI

    猫猫分享,必须精品 素材代码地址:http://blog.csdn.net/u013357243/article/details/44976175 原文地址:http://blog.csdn.net/ ...

  9. iOS开发之高级视图—— UITableView(四)自定义Cell

    当我们使用UITableView的时候,经常需要自定义Cell,这个例子展示了一个简单的自定义的Cell. HeroViewCell.h // // HeroViewCell.h // ExtendC ...

最新文章

  1. NASM、MASM浅谈
  2. 中国男人何时回归家庭?(转)
  3. 硬盘显示容量和实际容量不符合_买移动固态硬盘纠结大半天?花2分钟看完这篇,购买时不再被坑...
  4. Android中使用Thread线程出现的问题
  5. 数据库基础(3)函数依赖-平凡依赖,完全依赖,部分依赖,传递依赖
  6. 4线-2线优先编码器
  7. docker本地仓库(本地镜像仓库)环境搭建
  8. 国外优秀JAVA技术网站推荐
  9. Amine-PEG-Pyrene,芘丁酸聚乙二醇氨基,Pyrene-PEG-NH2
  10. 精确光源 Punctual Light Source
  11. K8s 之 ReadinessProbe(就绪探针)使用的迷惑
  12. 总体标准差、样本标准差、标准误差
  13. HTTP请求返回状态码详解
  14. 计算机基础_001_栈是什么
  15. layui实现导出全部数据Excel
  16. 美国泛达网络:新一代通用型数据中心机柜
  17. rust2020几月上架ps4_《腐蚀Rust》将于上架PS4,老玩家:爆肝警告,入坑需谨慎
  18. PostgreSQL 12 `GRANT` 命令
  19. 盘点不常用却很有用的代码 ,欢迎大家留言
  20. 防止tweak依附,App有高招;破解App保护,tweak留一手

热门文章

  1. OpenDigg前端开源项目月报201704
  2. HDU5886 Tower Defence 【两遍树形dp】【最长链预处理】
  3. BZOJ 3573 米特运输
  4. CRichEdit小记
  5. OpenLayers 动态添加标记(Marker)和信息窗(Popup)
  6. valgrind——Cachegrind分析CPU的cache命中率、丢失率,用于进行代码优化。
  7. 实现无刷新DropDownList联动效果
  8. JVM虚拟机参数配置官方文档
  9. SSE2 Intrinsics各函数介绍
  10. opencv 检测直线、线段、圆、矩形