Android程序開發(fā)之UIScrollerView里有兩個(gè)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后的滾動(dòng)條 _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; }
以上內(nèi)容是小編給大家介紹的Android程序開發(fā)之UIScrollerView里有兩個(gè)tableView 的詳細(xì)介紹,希望對大家有所幫助!
- Android使用Scroller實(shí)現(xiàn)彈性滑動(dòng)效果
- Android自定義View彈性滑動(dòng)Scroller詳解
- Android用Scroller實(shí)現(xiàn)一個(gè)可向上滑動(dòng)的底部導(dǎo)航欄
- 詳解Android應(yīng)用開發(fā)中Scroller類的屏幕滑動(dòng)功能運(yùn)用
- android使用 ScrollerView 實(shí)現(xiàn) 可上下滾動(dòng)的分類欄實(shí)例
- 深入理解Android中Scroller的滾動(dòng)原理
- Android Scroller完全解析
- Android Scroller及下拉刷新組件原理解析
- Android Scroller大揭秘
- android開發(fā)通過Scroller實(shí)現(xiàn)過渡滑動(dòng)效果操作示例
相關(guān)文章
Android 個(gè)人理財(cái)工具二:使用SQLite實(shí)現(xiàn)啟動(dòng)時(shí)初始化數(shù)據(jù)
本文主要介紹 Android 使用SQLite實(shí)現(xiàn)啟動(dòng)時(shí)初始化數(shù)據(jù),這里對SQLite 的數(shù)據(jù)庫進(jìn)行詳解,附有示例代碼,有興趣的小伙伴可以參考下2016-08-08Android中ListView下拉刷新的實(shí)現(xiàn)方法實(shí)例分析
這篇文章主要介紹了Android中ListView下拉刷新的實(shí)現(xiàn)方法,涉及Android操作ListView的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10Android開發(fā)實(shí)現(xiàn)圖片切換APP
這篇文章主要介紹了Android開發(fā)實(shí)現(xiàn)圖片切換APP,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-12-12flutter ExpansionTile 層級菜單的實(shí)現(xiàn)
這篇文章主要介紹了flutter ExpansionTile 層級菜單的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07Android中關(guān)于Notification及NotificationManger的詳解
本篇文章小編為大家介紹,Android中關(guān)于Notification及NotificationManger的詳解。需要的朋友參考下2013-04-04Android自定義ViewGroup之第一次接觸ViewGroup
這篇文章主要為大家詳細(xì)介紹了Android自定義ViewGroup之第一次接觸ViewGroup,感興趣的小伙伴們可以參考一下2016-06-06Android編程之手機(jī)壁紙WallPaper設(shè)置方法示例
這篇文章主要介紹了Android編程之手機(jī)壁紙WallPaper設(shè)置方法,結(jié)合實(shí)例形式分析了Android手機(jī)壁紙WallPaper的相關(guān)設(shè)置與使用技巧,需要的朋友可以參考下2017-08-08