tableView的基本使用(改良版)
@interface ViewController ()<UITableViewDataSource, UITableViewDelegate>
{
int i;//用来计算接受通知的次数
}
@property(nonatomic,strong)UITableView * tableView;
@end
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.navigationController.navigationBarHidden = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(通知要执行的方法) name:@"有新消息了" object:nil];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 屏幕宽度, 屏幕高度 - 49) style:UITableViewStyleGrouped];
self.tableView.bounces = NO;
self.tableView.backgroundColor = 灰色;
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.sectionFooterHeight = 0;
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];//在这里注册一下,数据源方法中就不用加判断语句了,否则数据源方法得加上if(cell == nil){创建新的cell};
}
#pragma mark - UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
//-----为cell添加数据----
cell.xxx = @"xxxxx";.....
return cell;
}
#pragma mark UITableViewDelegate
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 0) {
return 300 * 屏幕宽度/375.0 + 20;
}
return 0;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (条件一) {
}else{
}
}
tableView的基本使用(改良版)的更多相关文章
- office全系列激活脚本-改良版
@ECHO OFFTITLE office 全版本系统激活@echo offfor /l %%a in (8,1,16) do (for /f "tokens=*" %%i in ...
- windows全系列激活脚本-改良版.cmd
@ECHO OFFTITLE Windows 全版本系统激活cscript //nologo %Systemroot%\system32\slmgr.vbs -skms 10.1.1.12ECHO 检 ...
- office全系列激活脚本-改良版.cmd
@ECHO OFFTITLE office 全版本系统激活@echo offfor /l %%a in (8,1,16) do (for /f "tokens=*" %%i in ...
- 优化改良版:数组,List,等集合需要加逗号或其它符合转成字符串
大家经常需要数组加逗号拼接成字符串的情况传统作法就是写for,foreach拼接, 现给出优化改良版数组,List,等集合需要加逗号或其它符合转成字符串方法: List<string> l ...
- 无焦点下获取条码枪返回值的Hook(再次改良版)
针对上一个版本再次改良,上除掉无用代码,新手绝对可以看懂! using System; using System.Collections.Generic; using System.Linq; usi ...
- Python开发程序:选课系统-改良版
程序名称: 选课系统 角色:学校.学员.课程.讲师要求:1. 创建北京.上海 2 所学校2. 创建linux , python , go 3个课程 , linux\py 在北京开, go 在上海开3. ...
- php接口post提交方法 (改良版)
$postData = "reqType=2&caller=15088719619&called=15068722845"; $result = send_post ...
- Headfirst设计模式的C++实现——迭代器(Iterator)改良版
iterator.h #ifndef _ITERATOR_H_ #define _ITERATOR_H_ class Iterator { public: ; ; }; #endif menu.h # ...
- 利用反射把数据库查询到的数据转换成Model、List(改良版)
之前也写过一篇这样的博文,但是非常的粗糙. 博文地址 后来看到了一位前辈(@勤快的小熊)对我的博文的评论后,让我看到了更加优雅的实现方式,于是重构了之前的代码. public static Li ...
随机推荐
- MSP430常见问题之LCD 显示驱动类
Q1:晶体一般都是接32768,然后使用液晶很正常.我打算将晶体接6M的替换32768,那么液晶还能正常显示吗A1:看你所用的LCM 模块时序极限是多少HZ,然后看6M情况下,MSP430去驱动LCM ...
- 浅谈MapControl控件和PageLayoutControl控件
1.MapControl控件是ArcObject(ArcEngine)中使用非常普遍的一个控件,它对应ArcMap中的DataView视图.MapControl控件实现的功能: 1)管理控件的外观.显 ...
- 7 个基本的 JS 函数【译】
本文由 伯乐在线 - 刘健超-J.c 翻译,进林 校稿.未经许可,禁止转载!英文出处:davidwalsh.name.欢迎加入翻译组. 我记得早期的 JavaScript ,要完成任何事情几乎都绕不开 ...
- Linux 命令 - ss: 查看套接字统计信息
命令格式 ss [options] [ FILTER ] 命令参数 -h, --help 显示帮助信息. -V, --version 显示版本信息. -n, --numeric 不解析服务名称. -r ...
- C#中thrift 中THttpHandler 传输数据 慢 slow 解决办法
1. 在用c# 写thrift的服务端,来相应http请求,在用结构体传输时,会遇到一个问题,就是(在用网络)传输数据特别慢, 这是由于在发生数据是用的TStreamTransport 导致每传一个数 ...
- SQL获取刚插入的记录的自动增长列ID的值
假设表结构如下: CREATE TABLE TestTable ( id int identity, CreatedDate datetime ) SQL2005获得新增行的自动增长列的语句如下: i ...
- 交叉编译lsof for android
Android 自带的那个 lsof 实际上是 toolbox 里的,功能十分单一,除了显示出所有进程的所有打开的文件外就什么都不能做,连说明也没有 :-( 于是为了 htop 用着爽一点,还是自己编 ...
- Oracle用户system解锁
1.首先进入sql plus窗口(参见上一篇文章) 2.进入后:输入select username,account_status from dba_users where username='SYST ...
- 分布式PostGIS系列【1】— 概述
一.Postgresql 分布式技术简介 二.分布式技术相关概念 三.分布式 Postgresql解决方案 四.相关资料与参考文献
- 暑假集训(4)第四弹 -----排列,计数(hdu1465)
题意概括:嗯,纵使你数次帮助小A脱离困境,但上一次,小A终于还是失败了.那数年的奔波与心血,抵不过轻轻一指,便彻底 湮灭,多年的友谊终归走向末路.这一切重击把小A彻底击溃! 不为什么,你到底还是要继续 ...