【代码笔记】iOS-UIScrollerView里有两个tableView
一,效果图。


二,工程图。

三,代码。
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的更多相关文章
- 【代码笔记】iOS-scrollerView里多个tableView加搜索框
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> #import "customCell.h&qu ...
- 【代码笔记】iOS-json文件的两种解析方式
一,工程图. 二,代码. #import "ViewController.h" #import "SBJson.h" @interface ViewContro ...
- 【代码笔记】iOS-点击城市中的tableView跳转到旅游景点的tableView,下面会有“显示”更多。
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...
- 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. ...
- WWDC 2014 Session笔记 - iOS界面开发的大一统
本文是我的 WWDC 2014 笔记 中的一篇,涉及的 Session 有 What's New in Cocoa Touch Building Adaptive Apps with UIKit Wh ...
- 【Unity Shaders】学习笔记——SurfaceShader(二)两个结构体和CG类型
[Unity Shaders]学习笔记——SurfaceShader(二)两个结构体和CG类型 转载请注明出处:http://www.cnblogs.com/-867259206/p/5596698. ...
- 【hadoop代码笔记】hadoop作业提交之汇总
一.概述 在本篇博文中,试图通过代码了解hadoop job执行的整个流程.即用户提交的mapreduce的jar文件.输入提交到hadoop的集群,并在集群中运行.重点在代码的角度描述整个流程,有些 ...
- 笔记-iOS 视图控制器转场详解(上)
这是一篇长文,详细讲解了视图控制器转场的方方面面,配有详细的示意图和代码,为了使得文章在微信公众号中易于阅读,seedante 辛苦将大量长篇代码用截图的方式呈现,另外作者也在 Github 上附上了 ...
- iOS 类似美团外卖 app 两个 tableView 联动效果实现
写在前面 首先声明哈,不是广告,我就是用的时候觉得这个功能比较好玩,就想着实现了一下.效果如图: 接下来简单的说一下思路吧~ 大体思路 可能我们看到这种功能的实现的时候,首先想着的是我在这个控制器中左 ...
随机推荐
- 让我们开启数据库无Linq、零sql时代
让我们开启数据库无Linq.零sql时代 Moon.Orm 5.0总论 第一部分 MQL Moon.Orm 5.0 (MQL版) 版本维护及下载 (跟踪发布) Moon.Orm 5.0系列文章 1. ...
- react经典进阶demo
这是我在官方文档上看到的,功能是实现(具体是什么,请往下看) 以下是json数据: [ {category: "Sporting Goods", price: "$49. ...
- 局部页面传值Model
1:新建个局部页面,将这里页面的Model数据传递过去,在局部页面进行和一般页面一样的操作就行. 这里和HTML.Action不一样,对于HTML.action来说,它是新建了一个action来进行传 ...
- ASP.NET MVC的TextBoxFor()和TextBox()
先来看看2者的语法:TextBoxFor():MvcHtmlString Html.TextBoxFor(Expression<Func<TModel,TValue>> exp ...
- 使用NuGet打包并发布至ProGet过程 (步骤详细,附python脚本)【上篇】
一.基本知识 (1)NuGet : NuGet是一个为大家所熟知的Visual Studio扩展,通过这个扩展,开发人员可以非常方便地在Visual Studio中安装或更新项目中所需要的第三方组件, ...
- 'display' VS 'visibility'
常用的display属性值: none此元素不会被显示并且不占用空间: block此元素显示为块级元素,此元素前后会带有换行符: inline默认,此元素会被显示为内联元素,元素前后没有换行符: in ...
- C#编程总结(五)多线程带给我们的一些思考
C#编程总结(五)多线程带给我们的一些思考 如有不妥之处,欢迎批评指正. 1.什么时候使用多线程? 这个问题,对于系统架构师.设计者.程序员,都是首先要面对的一个问题. 在什么时候使用多线程技术? 在 ...
- mysql分页查询详解
我们做的后端项目一般都会有admin管理端,当管理端将要展示数据的时候,就需要用到分页.所以分页的考查在面试中也相当多.在mysql中进行分页查询时,一般会使用limit查询,而且通常查询中都会使用o ...
- InfluxDB学习之InfluxDB的HTTP API写入操作
HTTP API也有两种操作:写入和查询,本文就先给大家介绍一下 InfluxDB的HTTP API的写入操作方式. 在InfluxDB学习的上一篇文章:InfluxDB学习之InfluxDB ...
- wso2esb简介
WSO2 ESB是一个轻量级的易于使用的企业服务资源总线,基于Apache Software License v2.0. WSO2 ESB 允许系统管理员和SOA架构师轻松的配置消息路由, 虚拟化, ...