views:

24

answers:

0

Hi,

I am inserting a UITableView as a subview in the RootView. The data is loaded asynchronously using ASIHTTPRequest. I want to resize the tableView frame size when the data finishes downloading, so that the tableview is scrollable. Please find the code below, I am stuck on this and would really appreciate any help.

// RootView which contains the CustomTableView and other views
@interface RootViewController{

CustomTableView *customTableView;
}

@property (nonatomic, retain) customTableView *customTableView;

@implementation RootViewController

@synthesize customTableView;


-(void)loadView{

self.customTableView = [[CustomTableView alloc] init]; 

//This is done so that the table occupies the bottom half of the view
self.customTableView.tableView.frame = CGRectMake(0, 250, 325, 400);
self.customTableView.tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight |    UIViewAutoresizingFlexibleWidth;
[self.view addSubview:self.customTableView.tableView];
}



// CustomTable - subclass of UITableView
@interface CustomTableView : UITableViewController <UITableViewDelegate,    UITableViewDataSource>{

NSMutableArray *data;
}

@property (nonatomic, retain) NSMutableArray *data;

@implementation CustomTableView

@synthesize data;

- (void)requestFinished:(ASIHTTPRequest *)request{

// The data reloads but the tableView is not scrollable. How to resize the frame which has been set above. 
[self.tableView reloadData];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section   {

return [self.data count];
}