---
title: "ScrowView具体用法"
author: "caoyudong"
date: "2014-12-30T10:32:22Z"
tags: []
categories: ["移动开发"]
slug: "scrowview"
draft: false
lastmod: "2014-12-30T10:35:20Z"
id: 2171097
url: "https://cydd.iteye.com/blog/2171097"
---

//UIView:
-(id)initWithFrame:(CGRect)frame :(id)target :(SEL)sel
{
    self=;
    if (self)
    {
        controller=target; //传一个id类型的controller
        ;
        f_tableA=; //f_ 表示设置为全局变量
        f_tableB=;
    }
    return self;
}


-(void)creatScrow
{
    scrow=initWithFrame:CGRectMake(0, 30, self.frame.size.width, self.frame.size.height-50)];
        scrow.directionalLockEnabled=YES;//只能一个方向滑动
        scrow.pagingEnabled = YES; //是否翻页
        scrow.backgroundColor = ;
        scrow.showsVerticalScrollIndicator =NO; //垂直方向的滚动指示
        scrow.indicatorStyle = UIScrollViewIndicatorStyleWhite;//滚动指示的风格
        scrow.showsHorizontalScrollIndicator = YES;//水平方向的滚动指示
        CGSize size=CGSizeMake(self.frame.size.width * 2, 0);
        ;
    ;
   ;
   ;
}


-(id)creatTableA
{
    UITableView *tableA=initWithFrame:CGRectMake(0, 0, .bounds.size.width, self.frame.size.height) style:UITableViewStylePlain];
    tableA.delegate=controller;//设置代理方法
    tableA.dataSource=controller;
    tableA.backgroundColor = ;
    ;
    return tableA;
}

-(id)creatTableB
{
    UITableView *tableB=initWithFrame:CGRectMake(self.frame.size.width, 0, self.frame.size.width, self.frame.size.height) style:UITableViewStylePlain];
    tableB.delegate=controller;//设置代理方法
    tableB.dataSource=controller;
    tableB.backgroundColor = ;
    ;
    return tableB;
}

//UIViewController:
//在代理方法中的写法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView==scrowView.f_tableA) 
{
}
if (tableView==scrowView.f_tableB) 
{
}
}