Change UIScrollView contentSize on tableView reload
My iphone application has this main view which contains 2 scrollviews. The first scrollview contains some information (this one has paging enabled and user scrolls horizontally) and the second scrollview contains the tableview.
I am using UIScrollview to load tableView even though the tableView is a subclass of UIScrollview. This is because somehow I am not able to get tableview to scroll if I don't load it as a subview of UIScrollview. Is this a problem because of multiple scrollviews?
Since the call to get the data for the table is Async, I wait for the request to get data (I am using ASIHTTPRequest) and then update the tableView when data is available.
This works fine so long as the tableView returns data that fits in the UIScrollView contentSize that I had set when loading the UIScrollView. When the number of Rows increase, the scrollView is not able to load all of it. It cannot increase the content size. I have tried to set the contentSize when table is being reloaded but it won't make any difference.
Is there any way I can change the contentSize of the UIScrollView depending on the numberOfRows that are returned by the tableView? Is there anyway I can get tableView to scroll? I am stuck on this. Appreciate any help.
Here is the code snippet that I am using
//UIScrollView and UITableView have retain properties and synthesize setup.
-(void)loadView{
self.customTableView =开发者_如何学C [[CustomTableView alloc] init];
self.tScrollView=[[UIScrollView alloc] initWithFrame:tableScrollViewFrame];
self.tScrollView.contentSize=CGSizeMake(320,500);
self.tScrollView.pagingEnabled = NO;
self.tScrollView.showsHorizontalScrollIndicator = NO;
self.tScrollView.showsVerticalScrollIndicator = NO;
self.tScrollView.scrollsToTop = NO;
self.tScrollView.delegate = self;
self.tScrollView.autoresizesSubviews = YES;
[self.tScrollView addSubview:customTableView.tableView];
}
-(void)didFinishLoadingData{
[self.customTableView reloadData];
}
I think this may be due the fact you are setting your contentSize before the data is finished loading. What happens if you do not set the contentSize?
精彩评论