可以左右滑动的UITableView(三)

2014-11-24 03:22:01 · 作者: · 浏览: 2
urn 6; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @Cell; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (nil == cell){ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.textLabel.text = @888888; return cell; } @end
3个TableView创建完了。

ViewController.h

#import 
  
   
#import OneViewController.h
#import TwoViewController.h
#import ThreeViewController.h

@interface ViewController : UIViewController
   
     @property (strong , nonatomic) UIScrollView* m_ScrollView; @property (strong , nonatomic) OneViewController* m_OneView; @property (strong , nonatomic) TwoViewController* m_TwoView; @property (strong , nonatomic) ThreeViewController* m_ThreeView; @end
   
  

ViewController.m

//
//  ViewController.m
//  左右滑动的TableView
//
//  Created by 杜甲 on 14-1-12.
//  Copyright (c) 2014年 杜甲. All rights reserved.
//

#import ViewController.h

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.

    self.m_ScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, self.view.frame.size.height)];
    self.m_ScrollView.contentSize = CGSizeMake(960, 480);
    self.m_ScrollView.scrollEnabled = YES;
    self.m_ScrollView.delegate = self;
    self.m_ScrollView.bounces = YES;
    self.m_ScrollView.pagingEnabled = YES;
    self.m_ScrollView.showsHorizontalScrollIndicator = NO;
    [self.view addSubview:self.m_ScrollView];
    
    
    
    self.m_OneView = [[OneViewController alloc] initWithStyle:UITableViewStylePlain];
    [self.m_ScrollView addSubview:self.m_OneView.view];
    
    self.m_TwoView = [[TwoViewController alloc] initWithStyle:UITableViewStylePlain];
    self.m_TwoView.view.frame = CGRectMake(320, 0, self.view.frame.size.width, self.view.frame.size.height);
    [self.m_ScrollView addSubview:self.m_TwoView.view];
    
    self.m_ThreeView = [[ThreeViewController alloc] initWithStyle:UITableViewStylePlain];
    self.m_ThreeView.view.frame = CGRectMake(640, 0, self.view.frame.size.width, self.view.frame.size.height);
    [self.m_ScrollView addSubview:self.m_ThreeView.view];
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end