uitableview

Layout problems after replacing UILabel with UITextView in a UITableViewCell

吃可爱长大的小学妹 提交于 2020-04-18 05:43:13
问题 I've got basic chat functionality as part of an App I'm building. It is basically a UITable View where the UITableViewCell only contains a UILabel (the chat message text) and a UIView (serving as a speech bubble, surrounding the text. Here's the code: class ChatMessageViewCellController: UITableViewCell { var ChatMessageText = UILabel() var ChatBubble = UIView() var leadingConstraint: NSLayoutConstraint! var trailingConstraint: NSLayoutConstraint! var isIncoming: Bool! { didSet { if self

Is there a simple way to delete specific custom cells from a UITableView?

 ̄綄美尐妖づ 提交于 2020-04-17 20:44:47
问题 I am trying to instantiate empty Buyer cells (custom cell) in my table view and then have the user populate the buyers' names. When the user presses the delete button for a row/cell, it should delete the corresponding row/cell regardless of whether or not the textfield for that row has been populated or not. Clearly, I am not getting the desired behavior. For example, when I press delete Row0 (whose textfield says "Buyer 0") and the tableview reloads, Buyer 0 is still there, but one of the

Swift开发:仿Clear手势操作(拖拽、划动、捏合)UITableView

大兔子大兔子 提交于 2020-04-17 03:32:26
【推荐阅读】微服务还能火多久?>>> 这是一个完全依靠手势的操作ToDoList的演示,功能上左划删除,右划完成任务,拖拽调整顺序,捏合张开插入。 项目源码: https://github.com/luan-ma/ClearStyleDemo.Swift 初始化 TDCToDoItem.swift 定义模型对象 TDCToDoListController.swift 继承自 UITableViewController, 演示UITableView操作 var items = [ TDCToDoItem(text: "Feed the cat"), TDCToDoItem(text: "Buy eggs"), TDCToDoItem(text: "Pack bags for WWDC"), TDCToDoItem(text: "Rule the web"), TDCToDoItem(text: "Buy a new iPhone"), TDCToDoItem(text: "Find missing socks"), TDCToDoItem(text: "Write a new tutorial"), TDCToDoItem(text: "Master Objective-C"), TDCToDoItem(text: "Remember your wedding anniversary

Creating a UITableView cell to have a dynamic height

故事扮演 提交于 2020-04-14 06:17:21
问题 I'm trying to create a tableview cell to accommodate texts with varying lengths and I need each cell to have a dynamic height. I've tried using the below but no show: tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = 410 Can anybody help me please? 回答1: To set automatic dimension for row height & estimated row height, ensure following steps to make, auto dimension effective for cell/row height layout. I just tested following steps and code and works fine.

Creating a UITableView cell to have a dynamic height

拥有回忆 提交于 2020-04-14 06:17:08
问题 I'm trying to create a tableview cell to accommodate texts with varying lengths and I need each cell to have a dynamic height. I've tried using the below but no show: tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = 410 Can anybody help me please? 回答1: To set automatic dimension for row height & estimated row height, ensure following steps to make, auto dimension effective for cell/row height layout. I just tested following steps and code and works fine.

iOS深入学习(UITableView:系列1-最基本的东西)

我怕爱的太早我们不能终老 提交于 2020-04-07 11:31:35
这是UITableView博客系列的第一篇,使用xib和arc编码,主要讲解一些UITableView使用过程中简单的、但是又容易被忽略的东西,而且我会告诉读者,怎样在使用了之后就再也不会忘记。 操作的步骤如下, (1)首先拖一个UITableView控件到xib文件上面,如下图, 这没有什么,大家不要太过于害怕UITableView,它只是一个UI控件,跟UIButton和UILabel没什么不一样,可以随意的拖拉。 (2)接下来我们在对应的xxxViewController中实例化这个UITableView对象,这里有一个小技巧需要说明一下,先点击xxxViewController.xib文件,这时候Xcode中显示的就是xib文件的内容,这时候双击xxxViewController.h文件,这时候在小窗口中打开了.h文件,这样就方便了下面的操作。 在xxxViewController.xib文件中点,击TableView,点击鼠标 右键 ,将其拖动到小窗口的xxxViewController.h文件中,如下图, (3)释放鼠标,这时候会弹出下面的界面, 这里我将UITableView对象命名为theTableView,你可以将其命名为任意的名字,这只是一个变量名称,任意你修改。点击Connect按钮,这样Xcode自动帮我们在xxxViewController

IOS基础控件-UITableView

给你一囗甜甜゛ 提交于 2020-04-07 11:07:35
一、UITableView介绍 1.iOS中显示数据列表最常用的一个控件,支持垂直滚动 2. UITableView的两种内置样式 UITableViewStylePlain UITableViewStyleGrouped 3.数据源(dataSource)和代理(delegate)理解 1> UITableView需要一个数据源(dataSource)来显示数据,UITableView会向数据源查询一共有多少行数据以及每一行显示什么数据等。没有设置数据源的UITableView只是个空壳。凡是遵守UITableViewDataSource协议的OC对象,都可以是UITableView的数据源 2> 通常都要为UITableView设置代理对象(delegate),以便在UITableView触发一下事件时做出相应的处理,比如选中了某一行。凡是遵守了UITableViewDelegate协议的OC对象,都可以是UITableView的代理对象 3>一般会让控制器充当UITableView的dataSource和delegate 4.数据源(dataSource) @required - (NSInteger) tableView :(UITableView *)tableView numberOfRowsInSection :(NSInteger)section;

iOS学习之分段Table View的使用(Grouped样式表格)

二次信任 提交于 2020-04-07 10:03:23
简介: 上篇做了Table View的一些介绍 ,还做了一个TableView 的Plain样式的例子,这篇我们学习Grouped样式表的例子,还有用到前面读取Plist的知识(见 iOS学习之 plist文件的读写 ),把Plist文件中的数据读取出来,放到Table view里展示出来。这里把全国30多个省份的城市,都列出来了,plist文件里还有城市的行政区,不过这里只列出省份和城市就ok了。效果图如下: 那么开始吧。 1、新建项目 新的一个名称为TableViewGrouped的Single View Application项目,打开项目的xib文件,拖拽TableView控件到xib文件中,摆正位置。 2、给新建的TableView找到他的归属 选中新添的TableView ,Connection Inspector ,找到 delegate 和 datasource ,从它们右边的圆圈拉线到 Files Owner 图标上,参考上篇的第3步: 3、设置Table View的属性为Grouped样式 4、导入plist文件 从其他文件夹导入Provineces.plist文件,这个文件我会传到源代码里,大家都能方便使用了,包括全国30个省份和城市,还有城市的区也有。 5、添加.h .m的实现代码。 .h文件添加一个property [cpp] view plain

iOS核心动画详解(CABasicAnimation)

心不动则不痛 提交于 2020-04-07 09:00:29
前言   上一篇已经介绍了核心动画在UI渲染中的位置和基本概念,但是没有具体介绍CAAnimation子类的用法,本文将介绍CABasicAnimation及其子类CASpringAnimation的用法和一些注意事项。 一、CABasicAnimation 1.什么是CABasicAnimation   CABasicAnimation是核心动画类簇中的一个类,其父类是CAPropertyAnimation,其子类是CASpringAnimation,它的祖父是CAAnimation。它主要用于制作比较单一的动画,例如,平移、缩放、旋转、颜色渐变、边框的值的变化等,也就是将layer的某个属性值从一个值到另一个值的变化。类似x -> y这种变化,然而对于x -> y -> z甚至更多的变化是不行的。 2.常用属性   @property(nullable, strong) id fromValue;   @property(nullable, strong) id toValue;   @property(nullable, strong) id byValue;   很明显,fromvalue表示初始状态,tovalue表示最终状态,byvalue是在fromvalue的基础上发生的变化,这个可以慢慢测试,主要还是from和to。 3.实例化方法   +

Plist获取数据到TableView

◇◆丶佛笑我妖孽 提交于 2020-04-07 08:33:26
// // ViewController.m // Plist 获取数据到 TableView // // Created by dc008 on 15/12/21. // Copyright © 2015 年 崔晓宇 . All rights reserved. // #import "ViewController.h" @interface ViewController ()< UITableViewDataSource , UITableViewDelegate > { UITableView *_tableView; NSArray *array; } @end @implementation ViewController - ( void )viewDidLoad { _tableView = [[ UITableView alloc ] initWithFrame :[[ UIScreen mainScreen ] bounds ]]; _tableView . delegate = self ; _tableView . dataSource = self ; [ self . view addSubview : _tableView ]; array = [ NSArray arrayWithContentsOfFile : [[ NSBundle