reloaddata

iOS - another thread needs to send reloadData to the mainthread

痴心易碎 提交于 2019-11-27 06:14:01
问题 I got a separate thread that creates a UIView object, inserts it into the UITableView's data source and then call reloadData on the UITableView. However, since it is a separate thread, it cannot call reloadData directly, it needs to make the mainthread do it... but how do you tell the mainthread to do it? Thanks 回答1: [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO]; 回答2: You can use dispatch async, this method allows you to marshal worker

TableView reloadData vs. beginUpdates & endUpdates

*爱你&永不变心* 提交于 2019-11-27 04:16:30
问题 I got a tricky problem regarding updating my TableView, i get different results using different methods of updating it, let me explain: Situation 1: I use [tbl reloadData]; where tbl is my TableView, to update the TableView - works as intended. Situation 2: I use: [tbl beginUpdates]; [tbl reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationRight]; [tbl endUpdates]; Where tbl is my TableView, and indexPaths is an array containing all the indexPaths present in the

How to keep UITableView contentoffset after calling -reloadData

谁都会走 提交于 2019-11-26 21:39:20
CGPoint offset = [_table contentOffset]; [_table reloadData]; [_table setContentOffset:offset animated:NO]; //unuseful // __block UITableView *tableBlock = _table; // [self performBlock:^(id sender) { // [tableBlock setContentOffset:offset]; // } afterDelay:2]; I know don't know of any delegate method which gets called after reloadData . And using afterDelay:2 which is kind of a hack may be too short or too long, so how can I implement it? I was recently working with reloadData -- reloadData doesn't change the contentOffset or scroll the table view. It actually stays the same if the offset is

Remembering scroll position on UITableView

[亡魂溺海] 提交于 2019-11-26 19:46:42
问题 I have a bit of a problem with my iOS app in xcode. I have a UITableView that loads a few hundred cells. When I scroll down to a specific cell and drill down to detailedviewcontrollers and return again the master view table has returned all the way to the top. I've had a look at the following 2 questions that are similar. How can I get the UITableView scroll position so I can save it? Setting scroll position in UITableView I still can't get these to work. I'm not the most experienced coder so

How to reload data in a TableView from a different ViewController in Swift

北战南征 提交于 2019-11-26 17:46:48
In a ViewController, I'm trying to reload data in a TableView in another ViewController like so: (self.presentedViewController as! tableViewController).table.reloadData() Where tableViewController is the class in the TableView's controller (It's not upper camel case, I know) and table is the TableView. Well, doing this yields "fatal error: unexpectedly found nil while unwrapping an Optional value" and I guess that makes sense since the "presentedViewController" hasn't been loaded yet. I also tried this: (self.navigationController!.viewControllers[self.navigationController!.viewControllers

How to keep UITableView contentoffset after calling -reloadData

僤鯓⒐⒋嵵緔 提交于 2019-11-26 09:06:51
问题 CGPoint offset = [_table contentOffset]; [_table reloadData]; [_table setContentOffset:offset animated:NO]; //unuseful // __block UITableView *tableBlock = _table; // [self performBlock:^(id sender) { // [tableBlock setContentOffset:offset]; // } afterDelay:2]; I know don\'t know of any delegate method which gets called after reloadData . And using afterDelay:2 which is kind of a hack may be too short or too long, so how can I implement it? 回答1: I was recently working with reloadData --

How to reload data in a TableView from a different ViewController in Swift

拟墨画扇 提交于 2019-11-26 05:37:02
问题 In a ViewController, I\'m trying to reload data in a TableView in another ViewController like so: (self.presentedViewController as! tableViewController).table.reloadData() Where tableViewController is the class in the TableView\'s controller (It\'s not upper camel case, I know) and table is the TableView. Well, doing this yields \"fatal error: unexpectedly found nil while unwrapping an Optional value\" and I guess that makes sense since the \"presentedViewController\" hasn\'t been loaded yet.

How to tell when UITableView has completed ReloadData?

大兔子大兔子 提交于 2019-11-26 01:38:50
问题 I am trying to scroll to the bottom of a UITableView after it is done performing [self.tableView reloadData] I originally had [self.tableView reloadData] NSIndexPath* indexPath = [NSIndexPath indexPathForRow: ([self.tableView numberOfRowsInSection:([self.tableView numberOfSections]-1)]-1) inSection: ([self.tableView numberOfSections]-1)]; [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; But then I read that reloadData is