Reputation: 3543
I have a UITableView. On the tap of a button i want to display my custom view, then, once the view is visible, remove a particular item from the tableview. The custom view hides the tableview so i would like the remove to occur after this new view is visible.
Currently, i have this, which adds the custom view and then should remove the item, and reload the table, but the reload is occurring just as the animation ends (i have an animation block, changing the views alpha), so i can see the update.
[self.view addSubview:customView];
[itemArray removeObject:object];
[self.tableView reloadData];
How can i delay the reload until after the view is visible?
Thanks.
Upvotes: 2
Views: 4164
Reputation: 5200
You mention you're animating the view yourself; you should call reloadData
when the animation completes by using something like:
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(methodThatCallsReloadData)];
// or even
[UIView setAnimationDelegate:self.tableView];
[UIView setAnimationDidStopSelector:@selector(reloadData)];
or if you're using the block-based API:
[UIView animateWithDuration:... completion:^(BOOL finished) {
[self.tableView reloadData];
}];
Upvotes: 1
Reputation: 441
or you can use the performSelector method :
[self performSelector:@selector(myOtherMethod) withObject:nil afterDelay:1.5];
Upvotes: 1
Reputation: 11038
Try adding reloadData to viewDidAppear
:
-(void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.tableView reloadData];
}
That should give you the required delay.
Upvotes: 3