开发者

Scrollview paging within a tableview

开发者 https://www.devze.com 2023-03-20 23:48 出处:网络
I want to create a scrollview with paging enabled,with 5 pages,but the problem is these page must hold tableview.how 开发者_如何学JAVAto do this.Try this :

I want to create a scrollview with paging enabled,with 5 pages,but the problem is these page must hold tableview.how 开发者_如何学JAVAto do this.


Try this :

scroll=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
    scroll.backgroundColor=[UIColor clearColor];
    scroll.pagingEnabled=YES;
    scroll.contentSize = CGSizeMake(320*5, 460);
    CGFloat x=0;
    for(int i=1;i<6;i++)
    {
        UITableView *table = [[UITableView alloc]initWithFrame:CGRectMake(x+10, 10, 300, 440) style:UITableViewStyleGrouped];
        table.delegate=self;
        table.dataSource=self;
        [scroll addSubview:table];
        [table release];
        x+=320;
    }
    [self.view addSubview:scroll];
    scroll.showsHorizontalScrollIndicator=NO;
    [scroll release];
0

精彩评论

暂无评论...
验证码 换一张
取 消