一,效果图。

二,工程图。

三,代码。

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. Node魔法堂:NPM入了个门

    一.前言 NPM作为Node的模块管理和发布工具,作用与Ruby的gem.Python的pypl或setuptools.PHP的pear和.Net的Nuget一样.在当前前端工程化极速狂奔的年代,即使 ...

  2. JavaScript基础—插曲02

    Js学习基础 1:关于js中的数组 这里面可以是键值对的形式来存储的,我们必须利用forIn来输出,这就相当于foreach一样. var dir = new Array(); dir['0'] = ...

  3. LINQ to SQL语句(5)之Order By

    适用场景:对查询出的语句进行排序,比如按时间排序等等. 说明:按指定表达式对集合排序:延迟,:按指定表达式对集合排序:延迟,默认是升序,加上descending表示降序,对应的扩展方法是OrderBy ...

  4. 有关微信开发中errorcode:-1 errmsg:system error 错误的一点原因

    如果你在微信开发中遇到{"errcode":-1,"errmsg":"system error,hints:[req_id:]"}这样的错误 ...

  5. 启用数据库的 Service Broker

    --is_broker_enabled为0未启用,为1启用SELECT name,is_broker_enabled FROM sys.databases WHERE name = 'DBNAME' ...

  6. SSH实例(2)

    在WebContent\WEB-INF\下新建两个文件:applicationContext.xml和web.xml. web.xml: <?xml version="1.0" ...

  7. 【Java每日一题】20161101

    package Nov2016; import java.util.HashMap; import java.util.Map; public class Ques1101 { public stat ...

  8. 【转】EL表达式 (详解)

    EL表达式      1.EL简介 1)语法结构        ${expression} 2)[]与.运算符      EL 提供.和[]两种运算符来存取数据.      当要存取的属性名称中包含一 ...

  9. 实现在Android 进程和线程

    进程和线程 如果某个应用程序组件是第一次被启动,且这时应用程序也没有其他组件在运行,则Android系统会为应用程序创建一个包含单个线程的linux进程.默认情况下,同一个应用程序的所有组件都运行在同 ...

  10. quickstart.sh

    #!/bin/bashjava_pid=`ps -ef | grep java | grep 'com.kzhong.huamu.sisyphus.QuickStartServer' | awk '{ ...