目标C中是否有任何方法可以知道表重载已结束?我必须在表重新加载后做一些代码。
答案 0 :(得分:0)
Try this codes:
[self.tableView reloadData];
# below I use myArr array to loop data for tableView
dispatch_async(dispatch_get_main_queue(), ^{
NSIndexPath* indexPath = [NSIndexPath indexPathForRow: ([self.tableView numberOfRowsInSection:([self.tableView numberOfSections]-1)]-1) inSection:([self.tableView numberOfSections]-1)];
enter code here
if(myArr == (indexPath+1)){
#execute your logic here
}
});
答案 1 :(得分:0)
TableView重新加载在下一次布局传递期间发生,这通常在您将控制权返回到运行循环时发生。
因此,在表视图重新加载后运行某些东西的一种方法是强制表视图立即执行布局:
[self.yourTableView reloadData];
[self.yourTableView layoutIfNeeded];
NSIndexPath* indexPath = [NSIndexPath indexPathForRow: ([self.yourTableView numberOfRowsInSection:([self.yourTableView numberOfSections]-1)]-1) inSection: ([self.yourTableView numberOfSections]-1)];
// Your Action goes here
另一种方法: 使用dispatch_async:
执行安排后布局代码以便稍后运行[self.yourTableView reloadData];
dispatch_async(dispatch_get_main_queue(), ^{
NSIndexPath* indexPath = [NSIndexPath indexPathForRow: ([self.yourTableView numberOfRowsInSection:([self.yourTableView numberOfSections]-1)]-1) inSection:([self.yourTableView numberOfSections]-1)];
// Check Index Path if it's last then perform your action
});
或强>
使用UITableView willDisplayCell方法
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row){
//end of loading
//Do whatever the Action required. Like Stop indicator, etc...
}
}
答案 2 :(得分:0)
您可以使用CATransaction
var initialHref = window.location.href;
navigator.splashscreen.show();
// Reload original app url (ie your index.html file)
window.location = initialHref;
navigator.splashscreen.hide();