【问题标题】:Scrollview paging within a tableview表格视图中的滚动视图分页
【发布时间】:2011-07-15 10:32:54
【问题描述】:

我想创建一个启用分页的滚动视图,有 5 个页面,但问题是这些页面必须包含 tableview。如何执行此操作。

【问题讨论】:

    标签: objective-c cocoa-touch ipad uitableview uiscrollview


    【解决方案1】:

    试试这个:

    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];
    

    【讨论】:

    • 你可以把这段代码放在rootViewController的loadView或者viewDidLoad方法中。
    • class rootview contoller 没有实现 uitableview deligate 协议,,,我得到了这个错误
    • 抱歉来晚了,您需要通过UIScrollView *scroll; 声明滚动,并且您必须在.h 文件&lt;UITableViewDataSource, UITableViewDelegate&gt; 中声明表视图委托
    猜你喜欢
    • 1970-01-01
    • 2017-05-04
    • 2013-12-30
    • 2016-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-29
    • 1970-01-01
    相关资源
    最近更新 更多