iOS开发之tableView(自用贴)
来源:互联网 发布:淘宝拼图模块怎么用 编辑:程序博客网 时间:2024/05/17 22:59
//声明:本贴为自用贴,介于本人使用习惯可能不大家的使用习惯不同,不喜勿喷。
//经常用(这些基本够用除非要加特技)
<UITableViewDataSource,UITableViewDelegate>//两个代理
UITableView*table=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
table.delegate=self;
table.dataSource=self;
[self.view addSubview:table];
#pragma mark 代理 //常用的四个代理
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;//一行section中cell的个数 不写,即默认为1
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 80;//cell的高度
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellStr=@"todayCell";//本人习惯用xib
tadayDataTableViewCell *cell = (tadayDataTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellStr];
if(cell ==nil) {
NSArray *nibArray = [[NSBundle mainBundle]loadNibNamed:@"tadayDataTableViewCell" owner:self options:nil];
cell = (tadayDataTableViewCell *)[nibArray objectAtIndex:0];
}
cell.selectionStyle=UITableViewCellSelectionStyleNone;//去除点击效果
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"点击了cell");
}
//可能用(小特技)
table.separatorStyle=UITableViewCellSeparatorStyleNone;//去除cell多余的分割线
table.scrollEnabled=NO;//table的滚动效果
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;//section的个数 不写,即默认为1
}
//右划删除(系统的,加特技的自己写)
/*
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//删除处理
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
return @"删除";
}
*///消除cell选择痕迹
/*- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[self performSelector:@selector(deselect) withObject:nil afterDelay:0.5f];
}
- (void)deselect
{
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:NO];
}
*/
//不常用
//section里的文字
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ return @"";}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
//section头的高度,可以写一些自己想要的section头(有悬浮效果,当然悬浮效果可以关)
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
//section头的view
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
//section底的高度
}
-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
//section底的view
}
- iOS开发之tableView(自用贴)
- iOS开发之label(自用贴)
- iOS开发之UIButton(自用贴)
- iOS开发之UISearchBar(自用贴)
- iOS开发之textfield(自用帖)
- IOS开发之TableView详解
- IOS开发之TableView详细解释
- IOS开发之tableview只选中一行
- IOS开发之tableview单选
- iOS开发之tableview的优化
- iOS开发之代码调用自定义tableView
- ios拼图游戏(五)之嵌套TableView和水平TableView
- iOS开发笔记--TableView详解(2)
- iOS开发笔记--TableView详解(2)
- ios开发 tableview小结
- iOS开发 精简TableView
- iOS之tableView优化
- iOS笔记之tableView
- Linux操作系统定时任务系统 Cron 入门
- Github使用指南
- [Shader学习笔记]一些向量的几何知识
- .launch文件分析
- ROR 基础
- iOS开发之tableView(自用贴)
- C#生成验证码
- http://www.jb51.net/article/37462.htm
- Python: scikit-image 彩色图像滤波
- TS科普9 传输流包层
- 将多条数据以横向排列生成报表
- sql server
- SVN报MKCOL request for ... 405 Method Not Allowed错误
- Android快速SDK(19)录音播放库SoundRecorder【傻瓜模式】