【代码笔记】iOS-TableViewOfTwoSecton
一,效果图。
二,工程图。
三,代码。
RootViewController.h

#import <UIKit/UIKit.h> @interface RootViewController : UIViewController
<UITableViewDataSource,UITableViewDelegate>
{
NSArray * dataArray;
NSArray * aboutArray;
} @end

RootViewController.m

#import "RootViewController.h" @interface RootViewController () @end @implementation RootViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. self.title=@"tableViewOfTwoSection";
//初始化背景图
[self initBackGroundView];
//初始化数据
[self initData];
}
#pragma -mark -funcitons
-(void)initBackGroundView
{
UITableView * tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 376) style:UITableViewStyleGrouped];
tableview.delegate = self;
tableview.dataSource = self;
[self.view addSubview:tableview]; }
-(void)initData
{
dataArray = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:@"脑筋急转弯", @"title", nil],[NSDictionary dictionaryWithObjectsAndKeys:@"儿童饮食", @"title", nil], [NSDictionary dictionaryWithObjectsAndKeys:@"儿童健康", @"title", nil],[NSDictionary dictionaryWithObjectsAndKeys:@"宝宝资讯", @"title", nil],nil]; aboutArray = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:@"关于", @"title", @"aboutViewController", @"class", nil], nil];
}
#pragma -mark -UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2; }
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(section==0)
{
return dataArray.count;
}
else if(section==1)
{ return aboutArray.count;
}
return 0;
} -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ID"];
if(cell==nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"ID"]; }
if(indexPath.section==0){
cell.textLabel.text =[[dataArray objectAtIndex:indexPath.row]objectForKey:@"title"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}else if(indexPath.section==1)
{
cell.textLabel.text = [[aboutArray objectAtIndex:indexPath.row]objectForKey:@"title"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.section==0)
{
if(indexPath.row==0)
{
NSLog(@"脑筋急转弯");
}else if (indexPath.row==1){
NSLog(@"儿童饮食");
}else if (indexPath.row==2){
NSLog(@"儿童健康");
}else if (indexPath.row==3){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://baby.163.com"]];
} }else if (indexPath.section==1) {
if(indexPath.row==0)
{
NSLog(@"关于");
}
}
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
【代码笔记】iOS-TableViewOfTwoSecton的更多相关文章
- IOS开发笔记 IOS如何访问通讯录
IOS开发笔记 IOS如何访问通讯录 其实我是反对这类的需求,你说你读我的隐私,我肯定不愿意的. 幸好ios6.0 以后给了个权限控制.当打开app的时候你可以选择拒绝. 实现方法: [plain] ...
- 【hadoop代码笔记】Mapreduce shuffle过程之Map输出过程
一.概要描述 shuffle是MapReduce的一个核心过程,因此没有在前面的MapReduce作业提交的过程中描述,而是单独拿出来比较详细的描述. 根据官方的流程图示如下: 本篇文章中只是想尝试从 ...
- 【hadoop代码笔记】hadoop作业提交之汇总
一.概述 在本篇博文中,试图通过代码了解hadoop job执行的整个流程.即用户提交的mapreduce的jar文件.输入提交到hadoop的集群,并在集群中运行.重点在代码的角度描述整个流程,有些 ...
- 【Hadoop代码笔记】目录
整理09年时候做的Hadoop的代码笔记. 开始. [Hadoop代码笔记]Hadoop作业提交之客户端作业提交 [Hadoop代码笔记]通过JobClient对Jobtracker的调用看详细了解H ...
- 笔记-iOS 视图控制器转场详解(上)
这是一篇长文,详细讲解了视图控制器转场的方方面面,配有详细的示意图和代码,为了使得文章在微信公众号中易于阅读,seedante 辛苦将大量长篇代码用截图的方式呈现,另外作者也在 Github 上附上了 ...
- <Python Text Processing with NLTK 2.0 Cookbook>代码笔记
如下是<Python Text Processing with NLTK 2.0 Cookbook>一书部分章节的代码笔记. Tokenizing text into sentences ...
- [学习笔记] SSD代码笔记 + EifficientNet backbone 练习
SSD代码笔记 + EifficientNet backbone 练习 ssd代码完全ok了,然后用最近性能和速度都非常牛的Eifficient Net做backbone设计了自己的TinySSD网络 ...
- DW网页代码笔记
DW网页代码笔记 1.样式. class 插入类样式 标签技术(html)解决页面的内容样式技术(css)解决页面的外观脚本技术 解决页面动态交互问题<form> ...
- 前端学习:JS(面向对象)代码笔记
前端学习:JS(面向对象)代码笔记 前端学习:JS面向对象知识学习(图解) 创建类和对象 创建对象方式1调用Object函数 <body> </body> <script ...
- 离屏渲染学习笔记 /iOS圆角性能问题
离屏渲染学习笔记 一.概念理解 OpenGL中,GPU屏幕渲染有以下两种方式: On-Screen Rendering 意为当前屏幕渲染,指的是GPU的渲染操作是在当前用于显示的屏幕缓冲区中进行. O ...
随机推荐
- Vue2.5开发去哪儿网App 首页开发
主页划 5 个组件,即 header icon swiper recommend weekend 一. header区域开发 1. 安装 stylus npm install stylus --s ...
- windows 系统安装git的方法
windows 系统安装git的方法 msysgit是Windows版的Git,从https://git-for-windows.github.io下载 安装默认步骤,一步步安装即可 安装完成后,在开 ...
- Linux发邮件
一.mail命令 1.配置 vim /etc/mail.rc 文件尾增加以下内容 set from=1968089885@qq.com smtp="smtp.qq.com"set ...
- Storm的acker确认机制
Storm的acker消息确认机制... ack/fail消息确认机制(确保一个tuple被完全处理) 在spout中发射tuple的时候需要同时发送messageid,这样才相当于开启了消息确认机制 ...
- linux free命令详解(一)
一. 作用 free命令可以显示当前系统未使用的和已使用的内存数目,还可以显示被内核使用的内存缓冲区. 二. 语法 free [选项] 三. 选项 默认情况下,即在没有选项的情况下,&qu ...
- Intellij IDEA 环境配置与使用
Intellij IDEA 是我感觉最牛X的IDE开发工具,没有之一! 先share一篇教程: http://pan.baidu.com/s/1i3fzJff 调整字体 设置默认的JDK 显示行号 版 ...
- Maven 的基本配置与使用
什么是Maven Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具. 发文时,绝大多数开发人员都把 Ant 当作 Java 编程项目的标准构 ...
- Android 开发服务类 05_ ApkPatchDemo
APP 增量更新服务端[https://github.com/cundong/SmartAppUpdates] import com.cundong.common.Constants; import ...
- 关于Android系统的启动流程
当按下Android设备电源键时究竟发生了什么?Android的启动过程是怎么样的?什么是Linux内核?桌面系统linux内核与Android系统linux内核有什么区别?什么是引导装载程序?什么是 ...
- Docker概念学习系列之虚拟化(系统虚拟化和容器虚拟化)
不多说,直接上干货! 虚拟化定义: 虚拟化是一种资源管理技术,是将计算机的各种实体资源,如服务器.网络.内存及存储等,予以抽象.转换后呈现出来,打破实体结构间的不可切割的障碍,使用户可以比原本的配置更 ...