在我的編碼中,表視圖將顯示,但是當我滾動表視圖時,它將完全滾動。我只滾動了表格視圖單元格。請任何人幫助我。這是我的代碼。如何添加TableView以UIScrollView的兩個部分作爲子視圖
[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];
您能更清楚嗎?什麼是問題 – vamsi575kg
你爲什麼使用UITableViewStylePlain。如果你需要兩節,那麼使用UITableViewStyleGrouped而不是UITableViewStylePlain。 –
這似乎是這個問題的重複: http://stackoverflow.com/questions/3422915/scrolling-a-uitableview-inside-a-uiscrollview –