一,效果图。

二,工程图。

三,代码。

RootViewController.h

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController
<UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource>
{
UIScrollView *_scrolView;
UITableView *_tableView;
UITableView *_tableView2;
UITableViewCell *_cell;
} @end

RootViewConroller.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 initBackGroundView];
}
#pragma -mark -functions
-(void)initBackGroundView
{
//tableView后的滚动条
_scrolView=[[UIScrollView alloc]initWithFrame:CGRectMake(0,19, 320, 460)];
_scrolView.contentSize=CGSizeMake(320*2, 460);
_scrolView.delegate=self;
_scrolView.pagingEnabled=YES;
_scrolView.showsVerticalScrollIndicator=NO;
_scrolView.bounces=NO;
[self.view addSubview:_scrolView]; //tableView1
_tableView =[[UITableView alloc]initWithFrame:CGRectMake(0, 19, 320, 460)];
_tableView.tag=1;
_tableView.delegate=self;
_tableView.dataSource=self;
_tableView.scrollEnabled=NO;
[_scrolView addSubview:_tableView]; //tableView2
_tableView2=[[UITableView alloc]initWithFrame:CGRectMake(320, 19, 320, 460)];
_tableView2.tag=2;
_tableView2.delegate=self;
_tableView2.dataSource=self;
_tableView2.scrollEnabled=NO;
[_scrolView addSubview:_tableView2]; }
#pragma -mark -UITableViewDelegate
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 125;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
_cell=[tableView dequeueReusableCellWithIdentifier:@"ID"];
if (_cell==nil) {
_cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ID"];
} _cell.selectionStyle=UITableViewCellSelectionStyleNone; if (tableView.tag==1){
_cell.textLabel.text=@"1"; }else if(tableView.tag==2){
_cell.textLabel.text=@"2"; }
return _cell; }
 
 

【代码笔记】iOS-UIScrollerView里有两个tableView的更多相关文章

  1. 【代码笔记】iOS-scrollerView里多个tableView加搜索框

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> #import "customCell.h&qu ...

  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项目里扒出来的json文件

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Menlo; color: #000000 } p.p2 { margin: 0.0px 0. ...

  5. WWDC 2014 Session笔记 - iOS界面开发的大一统

    本文是我的 WWDC 2014 笔记 中的一篇,涉及的 Session 有 What's New in Cocoa Touch Building Adaptive Apps with UIKit Wh ...

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

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

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

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

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

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

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

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

随机推荐

  1. 类库,委托,as.is,var,泛型集合

    类库: 就是让别人调用你写的方法,并且不让别人看到你是怎么实现的.(比如说一些核心文件) 如果有功能你不会做,需要别人帮忙,那么你的同事可以帮你写好一个类,然后你来调用这个类中的方法,完成你的项目. ...

  2. 帝国cmsV6.6版数据表

    信息表:每个模型都有以下六个表 phome_ecms_news 新闻系统模型-主表 phome_ecms_news_data_1 新闻系统模型-副表1 副表可无限增加 信息表 phome_ecms_n ...

  3. Node.js系列之ubuntu环境搭建

    ctrl+alt+t打开终端(命令行) 一.准备Node.js所依赖的包(g++,curl,python等) sudo apt-get install g++ curl libssl-dev apac ...

  4. VC中实现文字竖排的简单方法

    好多人都觉得在VC中实现文字竖排是一件很难的事情,其实可以使用“躺”着的字体很方便的实现文字竖排. Windows中有一些字体是“躺”着的,例如:@Fixedsys.@System.@宋体.@黑体等等 ...

  5. 一文读懂UGC:互联网上的生态秘密

    转载自近乎: UGC(User- Generated Content)用户原创生产内容,它是相对于PGC(Professionally-produced Content)专业生产内容的一种内容来源,简 ...

  6. 使用泛型元组替代out与ref形式传参

    我们在开发的时候,都会常常遇到一个问题,如何为逻辑上返回多个对象设计方法签名.通常我们会想到使用out或ref修饰参数,或者麻烦些自己设定一个类型内部包含多个Object类型属性来接收多个返回值.这两 ...

  7. CSS选择器(一)

    CSS选择器包括标签选择器.ID选择器.类选择器.伪类和伪对象选择器.子选择器.相邻选择器.属性选择器.通用选择器.包含选择器.分组选择器.指定选择器等选择器,分为标签选择器.ID选择器.类选择器.特 ...

  8. mysql学习笔记 第五天

    使用分区数据表: 分区数据表和merge数据表具有相似的作用,但是分区数据表确确实实是一个数据表 ,不像merge是列出数据表的逻辑关系,并且分区数据表可以包括像myisam以外的 的数据表.创建分区 ...

  9. spring的使用《一》

    在前边的文章中说明了,如何搭建一个spring的开发环境,简单回顾下就是把spring的jar包导入工程中,如果是在javaWeb项目中是放在lib目录下,然后在web.xml文件中进行配置,配置sp ...

  10. chkconfig系统服务启动设置

    chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息. 谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接. 使用语法:chkconfig [--a ...