首先声明本篇博文是作者原创,在QQ群里看到一枚猿友求助,问题描述:使用UItableView 实现在表头里点击不同的按钮,去刷新当前的界面(界面是大的 cell),自己就实现了一下. 实验原材料:故事版(storyBoard).xib.UItableView.通知中心 技术点:多cell 的切换.通知的收发.*通知用完及时移除 先看效果图: 默认的当前界面是左图.点击“课程介绍”按钮就刷新为左图,点击“课程讨论”按钮就刷新为中图,点击“作品介绍”按钮就刷新为右图.          实现代码上传…
遵循UIGestureRecognizerDelegate协议: 1.0添加手势   - (void)addTapGest {    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap)];    tap.delegate = self;    [self.tableView addGestureRecognizer:tap];} 2.拦截部分…
转载请注明出处. 今天在调试代码的时候,在tableviewcell上添加button,发现button快速点击的话,是看不出点击效果的,查找资料发现, ios7上UITableViewCell子层容器是UITableViewCellScrollView, ios6的则是UITableViewCellContentView.点击效果应该是被ScrollView的触摸延迟给阻拦了. 经过一番摸索,终于找到解决方法. 第一步:将 tableView  的 delaysContentTouches 设…
ios7 =< System Version< ios8 : ios7 =< System Version < ios8  下 button.superview.superview .superview 是获取按钮所在的cell  NSLog(@"2: cell ---- %@", button.superview.superview.superview); 2014-10-07 10:23:55.583 NeiHanShe[1407:60b] 2: cell…
一.UITableView的UITableViewStyle 样式分为UITableViewStylePlain和UITableViewStyleGrouped两种: plain样式下区头和区尾是悬浮的(即拖动表的时候区头和区尾不会消失,一直显示在界面上): grouped样式区头和区尾是随表一起滑动的.静态的tableview需要分区时(XIB)样式只能是Grouped 二.表头和表尾 通过代码设置 tableHeaderView(表头):表最上面的区域 tableFooterView(表尾)…
实现步骤: 1.修改数据模型数组 给模型数组的某个位置增加一个模型 2.执行以下代码 NSIndexPath *indexPath = [NSIndexPath indexPathForRow: inSection:section]; [tableView beginUpdates]; [tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; [tableView e…
类似这种,我不想让下面那些空的显示. 很简单: self.tableView.tableFooterView = [[UIView alloc] init]; 加完这句之后就变成了这样:…
最近在项目中经常用到UITableView中的cell中带有UITextField或UITextView的情况,然后在这种场景下,当我们点击屏幕较下方的cell进行编辑时,这时候键盘弹出来会出现遮挡待输入的cell,导致我们无法很方便地查看到我们输入的内容,这样的体验是非常不好的.这个问题在之前我们的随笔iOS学习——键盘弹出遮挡输入框问题解决方案中也有讲过对应的解决方案,但是该方案在最近的应用中还有点小问题,我们在这里重新进行处理好. 一 主控制器为UITableViewController或…
- (void)buttonClick:(id)senser{    NSInteger tag = [senser tag];    NSLog(@"the button tag is %d",tag);    for (int row = 0; row<6; row++)    {        NSIndexPath *indexPathHighlight = [NSIndexPath indexPathForRow:row inSection:0];           …
以下是两种实现效果 1. 自定义cell 继承UITableViewCell 重写 -(void)setSelected:(BOOL)selected animated:(BOOL)animated { } -(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated { } 里面不写任何东西 注意重写的时候一定要有带animated 方法,不然还是无效 2.点击单元格 取消选中单元格 //  点击单元格的时候取消选中单元格 -(…
一.UITableView的简单使用 显示要素: 1.显示多少给区组 2.显示多少行数据 3.每行显示什么内容 代理不会提醒你有什么方法没调用,但是UITableViewDataSource会 1)用代码创建一个UITableView UITableView *tableview =[[UITableView alloc]initWithFrame:CGRectMakr(0,0,[UIScreen mainScreen].bounds.size.width,[UIScreen mainScree…
(1)效果 (2)源码与资源下载 http://pan.baidu.com/s/1pJLo2PP (3)总结 --核心是利用UITableView里面自带的cell来制作样式同样的cell. 与之对应的是,由于不是整个xib文件,所以载入这个cell时有一些差别,仅仅须要在缓存池中取就可以(利用ID). +(instancetype)cellWithTableView:(UITableView *)tableView{ static NSString *ID=@"app"; WPApp…
假设想实现滑动cell时,cell右边就能显示一个删除button,则要实现tableview 下边方法: - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 让一个cell实现滑动出现删除button 我们删除cell.一般调用方法 [tableView…
本篇博客方便自己检索使用.资源链接 下面是制作效果图,点击删除按钮,就能将该cell删除: 下面是主要的代码: #define KSUPER_TAG 20000 #define KDEFAU_TAG 10000 #import "WholeViewController.h" #import "HJ_CELL_3.h" #import "HJ_CELL_4.h" #import "NULL_CELL.h" #import &qu…
#import <UIKit/UIKit.h> @interface TestCell : UITableViewCell @property (weak, nonatomic) IBOutlet UIButton *btnTest; @end #import "ViewController.h" #import "TestCell.h" #import <objc/runtime.h> static void *btnIndexPathKe…
//一个section刷新 NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:]; [tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic]; //一个cell刷新 NSIndexPath *indexPath=[NSIndexPath indexPathForRow: inSection:]; [tableView relo…
//一个section刷新 NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:]; [tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic]; //一个cell刷新 NSIndexPath *indexPath=[NSIndexPath indexPathForRow: inSection:]; [tableView relo…
#pragma mark - 选择cell: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; FollowUpSelectViewCell *cell = (FollowUpSelectViewCell *)[tableView cellFo…
#import "ViewController.h" #import "NewsTableViewCell.h" #define UISCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) #define UISCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) @interface ViewController ()<UITableViewDat…
//一个section刷新 NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2]; [tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic]; //一个cell刷新 NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0]; [tableView r…
方式一:cell的底部添加一个UIView 1.在tableViewController的viewDidLoad中取消系统的分割线 // 取消系统的分割线 self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 2.在自定义cell的底部添加一个UIView,高度设置为1,并设置颜色,如果感觉分割线过于明显,可以修改透明度.  方式二:设置cell的separatorInset和layoutMargins属性 在cel…
1.通过xib创建一个cell,将label进行上左下右,进行适配, self.automaticallyAdjustsScrollViewInsets = NO; self.edgesForExtendedLayout = UIRectEdgeNone;//将原点移动到navigationBar下面去了 tableView.estimatedRowHeight = 37.0;//估计cell的高度 tableView.rowHeight = UITableViewAutomaticDimens…
http://www.aichengxu.com/iOS/11143168.htm 一.准备数据 (这是一个元组,第一个元素为英雄的名字;第二个元素为英雄头像图片的名字,格式为.PNG,如果为其他的格式,则需要将格式写出来:第三个元素为英雄常用说语句:第四个为英雄介绍.) data = ([“阿狸”,”阿木木”, “艾瑞莉娅”,”锤石”, “崔斯特”,”厄运小姐”,”弗拉基米尔”, “盖伦”, “赫卡里姆”, “加里奥”,”贾克斯”, “婕拉”, “卡尔玛”,”卡萨丁”,”卡兹克”,”库奇”,…
方法如下: 一般collectionView 或者 tableview都有自带的点击函数,如下: , collectionView -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ //一般情况,cell不是自定义 UICollectionViewCell * cell = (UICollectionViewCell *)[coll…
优化tableView加载cell与model的过程 效果图 说明 1. 用多态的特性来优化tableView加载cell与model的过程 2. swift写起来果然要比Objective-C简洁了不少 源码 https://github.com/YouXianMing/Swift-TableViewDemo https://github.com/YouXianMing/OC-TableViewDemo // // ViewController.swift // Swift-TableView…
UITableView设置为UITableViewStyleGrouped样式会出现多余间距,以前遇到过这样的问题,自己以为不难,只是一个知识点,也没太在意 ,今天又碰到了,发现自己把它给忘了,所以还是记下来好点. 1.问题 self.tableView=[[UITableView alloc]initWithFrame:CGRectMake(, , self.view.bounds.size.width, self.view.bounds.size.height-) style:UITable…
使用HVTableView动态展开tableView中的cell 效果: 源码: HVTableView.h 与 HVTableView.m // // HVTableView.h // HRVTableView // // Created by Hamidreza Vakilian on 25/11/2013 // Copyright (c) 2013 Hamidreza Vakilian. All rights reserved. // Website: http://www.infracy…
场景: 子类化Cell中有button,拥有选中式样,点击第一个Cell中的button后,Cell一中的button获得选中式样.可是当点击Cell二中的button时.Cell一中的button选中式样依旧存在,即同一时候存在两个选中的button. 解决方法: 在子类化的Cell中,定义一个 static UIButton *selectedButton; 必须是 static 静态变量. 然后在点击方法中. - (void)headerButtonClickAction:(UIButto…
转自:http://blog.csdn.net/tianyou_code/article/details/54426494 //一个section刷新 NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:]; [tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic]; //一个cell刷新 NSIndexPath *indexP…
效果图: 左边图片的代码: // // SecViewController.m // UI__多个TableView练习 // // Created by dllo on 16/3/17. // Copyright © 2016年 dllo. All rights reserved. // #import "SecViewController.h" @interface SecViewController () < UITableViewDataSource, UITableVi…