@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的基本使用(改良版)的更多相关文章

  1. office全系列激活脚本-改良版

    @ECHO OFFTITLE office 全版本系统激活@echo offfor /l %%a in (8,1,16) do (for /f "tokens=*" %%i in ...

  2. windows全系列激活脚本-改良版.cmd

    @ECHO OFFTITLE Windows 全版本系统激活cscript //nologo %Systemroot%\system32\slmgr.vbs -skms 10.1.1.12ECHO 检 ...

  3. office全系列激活脚本-改良版.cmd

    @ECHO OFFTITLE office 全版本系统激活@echo offfor /l %%a in (8,1,16) do (for /f "tokens=*" %%i in ...

  4. 优化改良版:数组,List,等集合需要加逗号或其它符合转成字符串

    大家经常需要数组加逗号拼接成字符串的情况传统作法就是写for,foreach拼接, 现给出优化改良版数组,List,等集合需要加逗号或其它符合转成字符串方法: List<string> l ...

  5. 无焦点下获取条码枪返回值的Hook(再次改良版)

    针对上一个版本再次改良,上除掉无用代码,新手绝对可以看懂! using System; using System.Collections.Generic; using System.Linq; usi ...

  6. Python开发程序:选课系统-改良版

    程序名称: 选课系统 角色:学校.学员.课程.讲师要求:1. 创建北京.上海 2 所学校2. 创建linux , python , go 3个课程 , linux\py 在北京开, go 在上海开3. ...

  7. php接口post提交方法 (改良版)

    $postData = "reqType=2&caller=15088719619&called=15068722845"; $result = send_post ...

  8. Headfirst设计模式的C++实现——迭代器(Iterator)改良版

    iterator.h #ifndef _ITERATOR_H_ #define _ITERATOR_H_ class Iterator { public: ; ; }; #endif menu.h # ...

  9. 利用反射把数据库查询到的数据转换成Model、List(改良版)

    之前也写过一篇这样的博文,但是非常的粗糙.    博文地址 后来看到了一位前辈(@勤快的小熊)对我的博文的评论后,让我看到了更加优雅的实现方式,于是重构了之前的代码. public static Li ...

随机推荐

  1. IE9+浏览器input文本框/密码框后面的小叉子/小眼睛清除

    为了方便我们的触控操作,IE高等浏览器针对input及input type="password"分别提供了快速清除钮(X图标)以及密码文字显示钮(小眼睛图标)的功能. 由于这经常跟 ...

  2. Git CMD - diff: Show changes between commits, commit and working tree, etc

    命令格式 git diff [options] [<commit>] [--] [<path>…​] git diff [options] --cached [<comm ...

  3. Unity3D鼠标点击物体产生事件

    如果需要处理鼠标点击物体的情况, 可以当数据接触物体时,鼠标手势改变,然后点击后和NPC产生对话等: using UnityEngine; using System.Collections; publ ...

  4. HDOJ2023求平均成绩

    求平均成绩 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  5. SQL中PERSISTED关键字

    PERSISTED 指定 SQL Server 数据库引擎将在表中物理存储计算值,而且,当计算列依赖的任何其他列发生更新时对这些计算值进行更新.将计算列标记为 PERSISTED,可允许您对具有确定性 ...

  6. Agile.Net 组件式开发平台 - 数据访问组件

    Agile.DataAccess.dll 文件为系统平台数据访问支持库,基于FluentData扩展重写,提供高效的性能与风格简洁的API,支持多种主流数据库访问. 当前市面上的 ORM 框架,如 E ...

  7. Nginx+Tomcat实现反向代理与动静分离

    1. 什么是动静分离  所谓动静分离就是通过nginx(或apache等)来处理用户端请求的静态页面,tomcat(或weblogic)处理动态页面,从而达到动静页面访问时通过不同的容器来处理. 2. ...

  8. 解释清楚c++的重载操作符【用自己的话,解释清楚】

    C++中对于内置的变量及标准库中常见的类定义类常见的操作符含义,对于自定义的类也可以通过关键字operate 重载操作符的含义. C++中支持重载的目的 诚然操作符的重载可以通过使用函数实现同样的功能 ...

  9. UvaLive7362 Fare(欧拉函数)

    题意:求1~n的素因子之和. 分析:欧拉函数 #include<cstdio> #include<cstring> #include<cctype> #includ ...

  10. (poj 3177) Redundant Paths

    题目链接 :http://poj.org/problem?id=3177 Description In order to <= F <= ,) grazing fields (which ...