一,效果图。

二,工程图。

三,代码。

RootViewController.h

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController
<UITableViewDelegate,UITableViewDataSource>
{
//列表
UITableView * _tableViewList;
//显示内容
UITableView * _tableViewMembers;
NSMutableArray * ListArray;
NSMutableArray * MembersArray;
} @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 initTableView]; }
#pragma -mark -functions
-(void)initTableView
{
//数据
MembersArray = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6", nil];
ListArray = [[NSMutableArray alloc] initWithObjects:@"娱乐明星",
@"体育明星",
@"生活时尚",
@"财经",
@"科技网络",
@"文化出版",
@"汽车",
@"动漫",
@"游戏",
@"星座命理",
@"教育",
@"企业品牌",
@"酷站汇",
@"腾讯产品",
@"营销产品",
@"有趣用户",
@"政府机构",
@"公益慈善",
@"公务人员",
@"快乐女生",
@"公共名人",
@"花儿朵朵", nil]; //列表tableView
_tableViewList = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 100, 416) style:UITableViewStylePlain];
_tableViewList.delegate = self;
_tableViewList.dataSource = self;
[self.view addSubview:_tableViewList]; //内容tableView
_tableViewMembers = [[UITableView alloc] initWithFrame:CGRectMake(100, 0, 240, 416) style:UITableViewStylePlain];
_tableViewMembers.delegate = self;
_tableViewMembers.dataSource = self;
[self.view addSubview:_tableViewMembers]; }
#pragma -mark -UITableViewDelegate
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (tableView == _tableViewList) {
return ListArray.count;
}else if(tableView == _tableViewMembers){
return MembersArray.count;
}
return 0;
} -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ if (tableView == _tableViewList) {
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ID"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"ID"];
} cell.textLabel.text = [ListArray objectAtIndex:indexPath.row];
return cell;
}else {
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ID"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"ID"];
}
cell.textLabel.text = [MembersArray objectAtIndex:indexPath.row];
return cell; }
} -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (tableView==_tableViewList) {
return 40;
}else if (tableView==_tableViewMembers){
return 80;
}else{
return 40;
}
} -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (tableView == _tableViewList) {
//去服务器下载数据,同时_tableViewMembers刷新。
[MembersArray removeAllObjects];
MembersArray=[[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3", nil];
[_tableViewMembers reloadData]; }else if(tableView==_tableViewMembers){
;
}
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
 
 

【代码笔记】iOS-推荐收听,左右两个tableView的更多相关文章

  1. 【代码笔记】iOS-UIScrollerView里有两个tableView

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  2. 【代码笔记】iOS-json文件的两种解析方式

    一,工程图. 二,代码. #import "ViewController.h" #import "SBJson.h" @interface ViewContro ...

  3. 【代码笔记】iOS-点击城市中的tableView跳转到旅游景点的tableView,下面会有“显示”更多。

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  4. iOS不得姐项目--推荐关注模块(一个控制器控制两个tableView),数据重复请求的问题,分页数据的加载,上拉下拉刷新(MJRefresh)

    一.推荐关注模块(一个控制器控制两个tableView) -- 数据的显示 刚开始加载数据值得注意的有以下几点 导航控制器会自动调整scrollView的contentInset,最好是取消系统的设置 ...

  5. 笔记-iOS 视图控制器转场详解(上)

    这是一篇长文,详细讲解了视图控制器转场的方方面面,配有详细的示意图和代码,为了使得文章在微信公众号中易于阅读,seedante 辛苦将大量长篇代码用截图的方式呈现,另外作者也在 Github 上附上了 ...

  6. 【Unity Shaders】学习笔记——SurfaceShader(二)两个结构体和CG类型

    [Unity Shaders]学习笔记——SurfaceShader(二)两个结构体和CG类型 转载请注明出处:http://www.cnblogs.com/-867259206/p/5596698. ...

  7. 【hadoop代码笔记】Mapreduce shuffle过程之Map输出过程

    一.概要描述 shuffle是MapReduce的一个核心过程,因此没有在前面的MapReduce作业提交的过程中描述,而是单独拿出来比较详细的描述. 根据官方的流程图示如下: 本篇文章中只是想尝试从 ...

  8. 【hadoop代码笔记】hadoop作业提交之汇总

    一.概述 在本篇博文中,试图通过代码了解hadoop job执行的整个流程.即用户提交的mapreduce的jar文件.输入提交到hadoop的集群,并在集群中运行.重点在代码的角度描述整个流程,有些 ...

  9. iOS 类似美团外卖 app 两个 tableView 联动效果实现

    写在前面 首先声明哈,不是广告,我就是用的时候觉得这个功能比较好玩,就想着实现了一下.效果如图: 接下来简单的说一下思路吧~ 大体思路 可能我们看到这种功能的实现的时候,首先想着的是我在这个控制器中左 ...

  10. IOS文件操作的两种方式:NSFileManager操作和流操作

    1.常见的NSFileManager文件方法 -(NSData *)contentsAtPath:path //从一个文件读取数据 -(BOOL)createFileAtPath: path cont ...

随机推荐

  1. 2012-09-10 23:30 如何解决HtmlAgilityPack得到的InnerText中有残留的script、样式的问题

    那么如何解决HtmlAgilityPack得到的InnerText中有残留的script.样式的问题呢,在google上搜索“HtmlAgilityPack script innerText”找到了s ...

  2. Git-Notes

    1.Git安装,直接在官网下载安装即可. 2.Git配置,使用config选项,配置名字和邮箱,如下所示 C:\Users\1yyg>git config --global user.name ...

  3. JavaSE高级之集合类

    ​下面的内容是对java中的集合类进行的总结,过段时间会分享java的网路编程,多线程等内容,欢迎批评指正. 1.Java中的集合是用来存放对象的,即集合是对象的集合,对象是集合的元素,java AP ...

  4. 【解决】查询无法完成,因为其包含的查找列数已超过管理员强制实施的查找列阈值。Error code=0x80070093; Error source=Groove

    前因: 修改了SharePoint Server 2013 下面的文档库的名称,原先2个汉字,现在8个汉字.结果,SkyDrive Pro 就无法同步了,无论是停止重新同步还是手动填写进行同步都不可以 ...

  5. 深入seajs源码系列三

    入口方法 每个程序都有个入口方法,类似于c的main函数,seajs也不例外.系列一的demo在首页使用了seajs.use(),这便是入口方法.入口方法可以接受2个参数,第一个参数为模块名称,第二个 ...

  6. ZOJ Problem Set - 1337 Pi 最大公约数

    这道题目的关键在于怎么求两个整数的最大公约数,这里正好复习一下以前的知识,如下: 1.设整数a和b 2.如果a和b都为0,则二者的最大公约数不存在 3.如果a或b等于0,则二者的最大公约数为非0的一个 ...

  7. [emacs] 使用ggtags浏览代码

    [emacs] 使用ggtags浏览代码 // */ // ]]>   [emacs] 使用ggtags浏览代码 Table of Contents 1 相关的连接 2 global简介 2.1 ...

  8. Elasticsearch 教程--分布式集群

    集群 补充章节 正如前文提到的,这就是第个补充的章节,这里会介绍 Elasticsearch 如何在分布式环境中运行. 本章解释了常用术语,比如 集群 (cluster), 节点 (node) 以及  ...

  9. [Web API] Web API 2 深入系列(6) Model绑定(上)

    目录 解决什么问题 Model元数据解析 复杂类型 ValueProvider ValueProviderFactory 解决什么问题 Model: Action方法上的参数 Model绑定: 对Ac ...

  10. 7.4 数据注解属性--Required

    Required attribute can be applied to a property of a domain class. EF Code-First will create a NOT N ...