Delay reloadData on UITableView

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.

Answers


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];
}];

Try adding reloadData to viewDidAppear:

-(void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self.tableView reloadData];
}

That should give you the required delay.


or you can use the performSelector method :

[self performSelector:@selector(myOtherMethod) withObject:nil afterDelay:1.5];

Need Your Help

jQuery array push on button click

javascript jquery arrays

i'm following up on a previous question I asked here

Need help modifying d3.js Collapsible Force Layout

javascript d3.js

I am modifying the d3.js Collapsible Force Layout where the nodes are given as circles.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.