
UITableVIew 表示图
小手一背爱谁谁
这个作者很懒,什么都没留下…
展开
-
iOS XibVIew加载的那些坑
1.view实体类加载XibView 重写 initWithFrame 方法,- (instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { UIView *view = [[[NSBundle mainBundle] loadNibNamed:self.description owner:self options:nil] lastObject]原创 2021-11-16 14:35:36 · 2147 阅读 · 0 评论 -
iOS UITableView高度简约手动计算并缓存
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.arr.count;}/// tableView刷新页面第一步 heightForRowAtIndexPath 代理方法-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *).原创 2021-08-24 10:51:54 · 526 阅读 · 0 评论 -
iOS tableView分区头自定义
// 设置分区高度 也可以使用代理方法_tableView.sectionHeaderHeight = 30;// tableView代理方法 设置分区高度(可以根据不同分区设置不同高度等实现自定义)- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)sectio...原创 2017-01-05 12:00:23 · 5252 阅读 · 0 评论 -
iOS tableView滚动至第一行
// 方法一[_tableViewsetContentOffset:CGPointMake(0,0)animated:NO];// 方法二[weakself.tableViewscrollToRowAtIndexPath:[NSIndexPathindexPathForRow:0inSection:0]atScrollPosition:UITableViewScrollPosit...原创 2016-12-23 15:47:13 · 2209 阅读 · 0 评论 -
iOS tableView与collectionView的样式切换以及间距问题处理
#define ScreenWidth ([UIScreen mainScreen].bounds.size.width)#define Screenheight ([UIScreen mainScreen].bounds.size.height)@property (weak,nonatomic) IBOutletUICollectionView *collectionV原创 2016-12-27 11:02:22 · 1339 阅读 · 0 评论 -
iOS 去掉TableViewCell 点击效果
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ // 1 松开手选中颜色消失 [tableView deselectRowAtIndexPath:indexPath animated:YES]; UITableViewCell ...原创 2016-03-31 13:55:59 · 21145 阅读 · 0 评论 -
iOS tableview分割线及点击效果处理方案
- (void)viewDidLoad {[superviewDidLoad];//加载时隐藏tableView 分割线[_tableViewsetSeparatorStyle:UITableViewCellSeparatorStyleNone];}- (UITableViewCell *)tableView:(UITab原创 2016-09-28 12:05:26 · 492 阅读 · 0 评论 -
iOS 输入框弹出键盘后改变tableView高度内容不被遮挡
// 键盘弹出改变tableview高度- (void)registerKeybordNotification { NSNotificationCenter *notification = [NSNotificationCenterdefaultCenter]; [notification removeObserver:self]; [原创 2016-10-10 17:27:33 · 2050 阅读 · 0 评论 -
iOS tableView表视图设置背景图片
经常遇到要给tableView设置背景图片的问题,但如果直接设置背景 backgroundView的话,背景图不会显示,原因是 tableView上的cell默认是不透明的颜色,所以解决方法是 让 cell透明即可: 1.给tableView设置背景view UIImageView *backImageView=[[UIImageViewalloc]initWit...原创 2016-05-23 18:45:06 · 7733 阅读 · 0 评论 -
iOS tableView三种计算动态行高方法
旧方法现在常规的动态行高的计算方法还是用[str boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size 这其中需要先传入一个最大尺寸和一个属性字典,特殊的格式要求都写在属性字典中。NSDictionary *attrs =转载 2016-05-23 11:18:01 · 6765 阅读 · 0 评论 -
iOS cell 背景颜色总有一款适合你
//方法一:右侧有箭头 箭头部分颜色不变cell .contentView .backgroundColor = [ UIColor redColor ];//方法二: 比较麻烦UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier :CellIdentifier];UIView* bgview =原创 2016-06-01 15:10:56 · 1741 阅读 · 0 评论 -
iOS tableView背景图和cell背景图
[tableView setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.png"]]]; //tableView 的背景图cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.pn原创 2016-06-01 14:47:01 · 1500 阅读 · 0 评论 -
iOS 自定义分区头加上图片 以及导航控制器 颜色随滑动改变
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ if(section==0) { return 200; } return 15;}-(UIView*)tableView:(UITableView *原创 2016-06-01 14:28:44 · 1265 阅读 · 0 评论 -
iOS tableView 一共0行时候去掉分割线 和 去掉多余分割线
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (_SegmentControl.selectedSegmentIndex == 1) { if (_serviecArr.count == 0) {原创 2016-05-04 19:10:00 · 1147 阅读 · 0 评论 -
iOS 加载NIB / xib 的 VIew
// .h#import #import #define NIB(x) (x *)[ViewUtil nib:#x]#define NIB_OWN(x, y) (x *)[ViewUtil nib:#x owner:y]#define REG_NIB(x, y) [ViewUtil table:x registerNib:#y]#def原创 2017-01-05 16:08:01 · 1405 阅读 · 0 评论 -
iOS 长截图开发
// 长截图 类型可以是 tableView或者scrollView 等可以滚动的视图 根据需要自己改- (void)saveLongImage:(UITableView *)table { UIImage* image = nil; // 下面方法,第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果,需要传NO,否则传YES。第三...原创 2017-01-05 19:23:46 · 6936 阅读 · 0 评论 -
iOS tableView 上下偏移
说一下问题吧,Xcode10 向下兼容到iOS8,iOS10以下版本会出现tableview向上或者向下偏移很是烦人。于是山寨了一个解决方案 该方法适用于向上偏移-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath ...原创 2019-01-16 10:32:23 · 1638 阅读 · 0 评论 -
iOS 一行代码实现tableView占位图
@interface UITableView (PlaceholderView)@property(nonatomic,strong)UIView *emptyView;@end#import "UITableView+PlaceholderView.h"#import <objc/runtime.h>@implementation UITableView (Pl...原创 2018-11-19 17:23:00 · 1281 阅读 · 0 评论 -
iOS tableView 加载到最后一行之后再刷新一次页面方法
// tableview 加载完成可以调用的方法 -(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if([indexPath row] =...原创 2018-10-21 01:11:53 · 1234 阅读 · 0 评论 -
iOS 简单实现树形结构列表
#import "ViewController.h"@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>@property(nonatomic,strong)UITableView *tableVIew;@property(nonatomic,strong)NSMutableAr...原创 2018-07-14 16:26:30 · 3663 阅读 · 0 评论 -
iOS tableViewCell展示 UIWebView加载所有内容后禁止滚动
是这样 cell 展示一个网页所有内容然后撑开cell刷新cell高度, 然后禁掉滚动事件。这样完美实现一个自适应高度的html/富文本样式。 // 赋值部分 NSUserDefaults 高度保存 写在cell里面 NSUserDefaults *user = [NSUserDefaults standardUserDefaults]; if ([user objectForK...原创 2018-05-30 17:37:46 · 1247 阅读 · 0 评论 -
iOS tableView头部拉伸并改变导航条渐变色
#import "TableViewController.h"static NSString *ident =@"cell";#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]#define RGB(r,g,b) RG原创 2018-05-05 17:24:30 · 894 阅读 · 0 评论 -
tableView 设置使用宏定义
//去掉多余的分割线#define TABLEVIEW_FOOTER(tableView)\\[tableView setTableFooterView:[[UIView alloc]initWithFrame:CGRectZero]];// 自适应高度#define TABLEVIEW_AUTOHIGHT(tableView,HIGHT)\\tableView.rowHeight = UITab...原创 2018-02-22 17:25:07 · 206 阅读 · 0 评论 -
iOS11 UITableView,UICollectionView适配
self.extendedLayoutIncludesOpaqueBars = YES; if (@available(iOS 11.0, *)) { self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } else { ...原创 2018-02-27 23:11:13 · 1106 阅读 · 0 评论 -
iOS 解决tableView和点击手势冲突问题
//接受手势代理UIGestureRecognizerDelegate> //添加手势 UITapGestureRecognizer *tap = [[UITapGestureRecognizeralloc] initWithTarget:selfaction:@selector(showOrHidenBar)]; tap.delegate=s原创 2017-09-07 19:41:13 · 1920 阅读 · 0 评论 -
iOS 导航条透明(以及自定义颜色)的方法,去掉导航条底部黑线,随着tableView滚动设置导航条变色
#import #define NAVBAR_CHANGE_POINT30@interface UINavigationBar (Awesome)- (void)lt_setBackgroundColor:(UIColor *)backgroundColor;- (void)lt_setElementsAlpha:(CGFloat)alpha;- (原创 2017-03-17 13:02:06 · 1840 阅读 · 0 评论 -
iOS tatableViewCell添加button并获取点击事件
UIButton *btn = [UIButtonbuttonWithType:UIButtonTypeCustom]; btn.frame =CGRectMake(cell.frame.size.width-70,20,50.0f, cell.frame.size.height-60); [btn setTitle:@"预约"forStat原创 2017-03-14 12:07:24 · 2590 阅读 · 0 评论 -
iOS 设置 tableView 代理, 注册 cell, 自适应高度.
// 设置 tableView 代理, 注册 cell, 自适应高度.+(void)tableViewRegister:(UITableView *)tableView identifier:(NSString *)identifier delegate:(id)delegate { tableView.estimatedRowHeight = 50.0f; table...原创 2017-03-22 14:22:06 · 683 阅读 · 0 评论 -
iOS tableViewCell 点击后没有任何变化
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BlackListCell" for原创 2016-05-04 11:14:06 · 858 阅读 · 0 评论 -
ios tableView去掉多余分割线 和最后一行分割线顶头显示
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (_partArr.count == 0) { // 去掉tableView分割线 (没有分割线) [tableView setSeparatorStyle:UITable...原创 2016-04-11 15:14:14 · 5167 阅读 · 0 评论 -
iOS tableviewCell点击行高变高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if(该indexPath被选中) { return 60 * 2.0; } return 60;}原创 2016-05-10 14:08:35 · 1247 阅读 · 0 评论 -
在tableview中用动画效果改变cell的高度
我们经常会碰到一些需要动画的地方,比如在TOP的发帖页面中,当我们选中一个文本编辑的cell时,cell的高度会动态的改变。 我们要的效果大概就是如下效果: 当我们选择一个cell的时候,我们就要改变它的高度,并且以动画的形式。 我们该如何实现这个效果呢?我们主要需要使用以下这两个方法: - (CG原创 2015-10-12 17:05:54 · 553 阅读 · 0 评论 -
动态计算UITableViewCell高度详解
不知道大家有没有发现,在iOS APP开发过程中,UITableView是我们显示内容常见的控件,本人觉得它是UIKit中最复杂的一个控件。今天要向大家介绍的就是如何动态计算UITableViewCell高度的一经验与技巧,在此做一些总结方便朋友们查阅。为了不让讲解空洞抽象,我还是用代码实例的方式进行讲解,这样更容易接收与学习。 本文将介绍四种情况下UITableViewCell的计算方式转载 2015-10-12 16:54:28 · 334 阅读 · 0 评论 -
修改点击cell时显示的颜色
首先清楚一点, 当我们点击cell的时候, 会默认是蓝色的效果@property(nonatomic,getter=isSelected) BOOL selected; // 是否被选中如果是YES, 选中cell的时候, cell会变成蓝色, 让用户知道被选中了如果是NO, 点击cell手指不离开, cell还是会显示蓝色, 当手指离开后, 蓝色消失有时候转载 2015-10-12 16:48:46 · 835 阅读 · 0 评论 -
swift tablevieCell自适应高度
自适应高度达到的效果实现方法:1. xcode新建个项目,选择 single View Application2. 打开main.storyboard 将tableview 拖到view controller中,并给tableview 拖入 tableview cell3. 给tableview cell 拖入 imageview 、label等控转载 2015-10-12 17:01:43 · 954 阅读 · 0 评论 -
Autolayout和Storyboard中动态UITableViewCell的高度
首先需要在Storyboard中创建好TableViewController,使用动态Cell,在Prototype Cells中设计好Cell界面。 接着,定义好Autolayout,注意Autolayout一定要在上下都绑定控件的位置,不要只从上到下定义,只有正确定义Autolayout,后面我们用到的systemLayoutSizeFittingSize方法才会返回正确的结果原创 2015-10-12 16:48:04 · 833 阅读 · 0 评论 -
取消tableView选中效果
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {//取消tableView选中效果 [tableView deselectRowAtIndexPath:indexPath animated:YES]; } self.ta原创 2015-10-12 16:45:08 · 1877 阅读 · 0 评论 -
UITableView中常用方法
/ 当某行没选择时候,调用此方法- (void)tableView:(UITableView *)tableViewdidSelectRowAtIndexPath:(NSIndexPath *)indexPath// 初始化每行时候,调用此方法- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtInd原创 2015-10-12 16:37:06 · 339 阅读 · 0 评论 -
TableViewCell 点击某行 该行高度增加
先定义一个变量来在函数- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 中添加代码来记录选定的行数 ,并调用tableView.reloadData然后在- (CGFloat)tableView:(UITableView *)tableView he原创 2015-10-12 17:04:43 · 536 阅读 · 0 评论 -
tableViewcell高度自适应
- (UITableViewCell *)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifier = @"Cell"; CustomCell *cell = (CustomCell *)[tableVi原创 2015-10-12 17:02:45 · 436 阅读 · 0 评论