【发布时间】:2013-08-08 20:22:50
【问题描述】:
在我的编码中,表格视图会显示,但是当我滚动表格视图时,它会完全滚动。我只滚动了表格视图单元格。请任何人帮助我。这是我的代码。
[super viewDidLoad];
scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,320,460)];
scrollview.showsVerticalScrollIndicator=NO;
scrollview.scrollEnabled=YES;
scrollview.userInteractionEnabled=YES;
[self.view addSubview:scrollview];
scrollview.contentSize = CGSizeMake(320,900);
[scrollview addSubview:recipePhoto];
[scrollview addSubview:detailLabel];
[scrollview addSubview:prizeLabel];
[scrollview addSubview:discountLabel];
[scrollview addSubview:saveLabel];
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 480, 600, 400) style:UITableViewStylePlain];
[tableView setAutoresizesSubviews:YES];
[tableView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
tableView.scrollEnabled = NO;
tableView.backgroundColor=[UIColor clearColor];
[tableView setDataSource:self];
[tableView setDelegate:self];
[scrollview addSubview:tableView];
[tableView reloadData];
【问题讨论】:
-
你能不能说的更清楚一点。有什么问题
-
你为什么使用 UITableViewStylePlain。如果您需要两个部分,请使用 UITableViewStyleGrouped 而不是 UITableViewStylePlain。
-
这似乎是这个问题的重复:stackoverflow.com/questions/3422915/…
-
表格视图已显示,但如果我单击单元格,它看起来像蓝色,如果我单击另一个单元格,它看起来像蓝色,但它不会改变选择所有单元格同时被选中。
标签: iphone ios uiscrollview