【发布时间】:2011-07-15 10:32:54
【问题描述】:
我想创建一个启用分页的滚动视图,有 5 个页面,但问题是这些页面必须包含 tableview。如何执行此操作。
【问题讨论】:
标签: objective-c cocoa-touch ipad uitableview uiscrollview
我想创建一个启用分页的滚动视图,有 5 个页面,但问题是这些页面必须包含 tableview。如何执行此操作。
【问题讨论】:
标签: objective-c cocoa-touch ipad uitableview uiscrollview
试试这个:
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];
【讨论】:
UIScrollView *scroll; 声明滚动,并且您必须在.h 文件<UITableViewDataSource, UITableViewDelegate> 中声明表视图委托