Situation: I'm trying to display a loading screen while waiting for my asynchronous connection to return with data to populate the tableview.
Problem: Creating and adding the load开发者_如何转开发ingscreen works fine, however, the tableview draws its lines over it, see screenshot:
.Code: I add the view with these lines:
-(void) viewDidLoad{
[super viewDidLoad];
_loadScreen = [[LoadScreen alloc] initWithFrame:self.view.bounds];
[self.view addSubview: _loadScreen];
[self fetchRemoteData];
}
Question: Is it possible to add the loading view ontop of the table? Or can i make sure the tableview does not draw its lines untill i call reloadData?
-Thanks in advance, W
I've done it like this many times:
-(void) viewDidLoad{
[super viewDidLoad];
_loadScreen = [[LoadScreen alloc] initWithFrame:self.view.bounds];
[self.tableView addSubview: _loadScreen];
self.tableView.hidden = YES;
[self fetchRemoteData];
}
- (void)dataFetchedSuccessfully
{
self.tableView.hidden = NO;
}
Just hide the tableview and show it again when the data has been loaded.
There is some approaches that will solve you problem:
-Set a footer view for the table view, so all lines should disappear.
self.tableView.tableFooterView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
-I assume that you use UItableViewController. If so self.view and self.tableView both represents the same view, so by setting:
self.tableView.hidden = NO;
It will hide even your loading view. What I encoure you to do is to create a custom view which has an table view as its subview. Then you can hide this table view by only showing an loading view.
Hope I could help.
精彩评论