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 ...
随机推荐
- 【杨氏矩阵+勾长公式】POJ 2279 Mr. Young's Picture Permutations
Description Mr. Young wishes to take a picture of his class. The students will stand in rows with ea ...
- hdu 4582 树状DP
思路:首先声明我是参考:http://blog.csdn.net/frog1902/article/details/9921845这位大牛的博客的. 他说的已经很详尽,但我还是要补充几点. 看完他的解 ...
- hdu 4005 边连通度与缩点
思路:先将图进行缩点,建成一颗树,那么如果这是一条单路径树(即最大点度不超过2),就不在能删的一条边,使得不连通.因为将其头尾相连,形成一个圈,那么删任意一条边,图都是连通的. 上面的是无解的情况,如 ...
- Linux下RPM软件包的安装及卸载
http://os.51cto.com/art/201001/177866.htm 在 Linux 操作系统下,几乎所有的软件均通过RPM 进行安装.卸载及管理等操作.RPM 的全称为Redhat P ...
- Bootstrap之导航栏(2015年-05年-20日)
<nav class="navbar navbar-default" style="border-color: transparent;">< ...
- ajax开发模拟后端数据接口
在做前端开发的时候,特别是一些业务逻辑集中在前端的开发中.我们经常需要自己来模拟获取到后台接口的数据.为什么要模拟?可能后台接口还没有开发完成,可能后台还没有数据返回,可能...等等原因.曾经,我也尝 ...
- 【转载】Android设计中的.9.png
转载自:腾讯ISUX (http://isux.tencent.com/android-ui-9-png.html) 在Android的设计过程中,为了适配不同的手机分辨率,图片大多需要拉伸或者压 ...
- JavaScript 参考手册
http://www.w3school.com.cn/jsref/index.asp https://developer.mozilla.org/zh-CN/docs/Web/JavaScript
- 搜索本地网络内所有可用的SQl实例
'搜索本地网络内所有可用的SQl实例 Dim instance As SqlDataSourceEnumerator = SqlDataSourceEnumerator.Instance Dim dt ...
- html5 canvas 圆形抽奖的实例
年底没啥,抽空学习了canvas,写了个html5抽奖的代码,造了个轮子,有用的童鞋可以拿走. 其中,canvas.onclick触发抽奖行为,概率可以在core.lottery()函数上添加,美化也 ...