你的位置:首页 > 软件开发 > 操作系统 > 【代码笔记】推荐收听,左右两个tableView

【代码笔记】推荐收听,左右两个tableView

发布时间:2016-06-16 10:00:05
一,效果图。二,工程图。三,代码。RootViewController.h#import <UIKit/UIKit.h>@interface RootViewController : UIViewController<UITableViewDelegate,UI ...

【代码笔记】推荐收听,左右两个tableView

一,效果图。

【代码笔记】推荐收听,左右两个tableView

二,工程图。

【代码笔记】推荐收听,左右两个tableView

三,代码。

RootViewController.h

【代码笔记】推荐收听,左右两个tableView
#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 initTableView];  }#pragma -mark -functions-(void)initTableView{  //数据  MembersArray = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6", nil];  ListArray = [[NSMutableArray alloc] initWithObjects:@"娱乐明星",         @"体育明星",         @"生活时尚",         @"财经",         @"科技网络",         @"文化出版",         @"汽车",         @"动漫",         @"游戏",         @"星座命理",         @"教育",         @"企业品牌",         @"酷站汇",         @"腾讯产品",         @"营销产品",         @"有趣用户",         @"政府机构",         @"公益慈善",         @"公务人员",         @"快乐女生",         @"公共名人",         @"花儿朵朵", nil];      //列表tableView  _tableViewList = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 100, 416) style:UITableViewStylePlain];  _tableViewList.delegate = self;  _tableViewList.dataSource = self;  [self.view addSubview:_tableViewList];    //内容tableView  _tableViewMembers = [[UITableView alloc] initWithFrame:CGRectMake(100, 0, 240, 416) style:UITableViewStylePlain];  _tableViewMembers.delegate = self;  _tableViewMembers.dataSource = self;  [self.view addSubview:_tableViewMembers];}#pragma -mark -UITableViewDelegate-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{  if (tableView == _tableViewList) {    return ListArray.count;  }else if(tableView == _tableViewMembers){    return MembersArray.count;  }  return 0;}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    if (tableView == _tableViewList) {    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ID"];    if (cell == nil) {      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"ID"];    }        cell.textLabel.text = [ListArray objectAtIndex:indexPath.row];    return cell;  }else {    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ID"];    if (cell == nil) {      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"ID"];    }    cell.textLabel.text = [MembersArray objectAtIndex:indexPath.row];    return cell;      }}-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{  if (tableView==_tableViewList) {    return 40;  }else if (tableView==_tableViewMembers){    return 80;  }else{    return 40;  }}-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{  if (tableView == _tableViewList) {    //去服务器下载数据,同时_tableViewMembers刷新。    [MembersArray removeAllObjects];    MembersArray=[[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3", nil];    [_tableViewMembers reloadData];      }else if(tableView==_tableViewMembers){    ;  }}- (void)didReceiveMemoryWarning{  [super didReceiveMemoryWarning];  // Dispose of any resources that can be recreated.}@end
【代码笔记】推荐收听,左右两个tableView

 

 


 

原标题:【代码笔记】推荐收听,左右两个tableView

关键词:ie

ie
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。