ITeye博客

ScrowView具体用法

caoyudong · 2014-12-30 10:32 · 移动开发 · Markdown

//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) { } }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。