uitableview

Filtering Array and displaying in Table View?

坚强是说给别人听的谎言 提交于 2020-01-13 05:20:06
问题 I want to search an dictionary of exercises for the name key and then show the filtered result in the table view. I am using this function func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { let filtered = exercises.filter { $0["name"] == searchText } print(filtered) if(filtered.count == 0){ searchActive = false; } else { searchActive = true; } self.exercisesTableView.reloadData() } Variables: var exercises = [Exercise]() var filtered: [NSMutableArray] = [] var

Swift 3- Update UI from main thread

淺唱寂寞╮ 提交于 2020-01-13 05:14:43
问题 I wanted to load data in background thread and update tableview/UI on main thread. Based on what's indicated here about threading, I was wondering if the code below is the way to go about it. I'm trying to load more data as user scrolls to a specific index and wanted to make sure the UI is not freezing due to threading. Thank you! func loadMore () { guard !self.reachedEndOfItems else { return } self.offset = self.offset! + 10 print("load more offset: \(self.offset)") var start = 0 var end = 0

Get all indexPaths in a section

江枫思渺然 提交于 2020-01-13 03:54:13
问题 I need to reload the section excluding the header after I do some sort on my tableview data. That's to say I just want to reload all the rows in the section. But I don't find a easy way to make it after I search for a while. reloadSections(sectionIndex, with: .none) not works here, for it will reload the whole section including the header, footer and all the rows. So I need to use reloadRows(at: [IndexPath], with: UITableViewRowAnimation) instead. But how to get the whole indexPaths for the

UITableView jumpy on scroll after changing cell height

折月煮酒 提交于 2020-01-13 03:51:07
问题 So I have a tableView where I want to change the height of a cell when tapped. Well, actually, I am replacing it with a bigger cell. On tap, I call: tableView.beginUpdates() tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) tableView.endUpdate() And then I modify my cellForRowAtIndexPath to return the right new cell and height. The cell's height is being automatically calculated by overriding sizeThatFits in the cell's implementation: override func sizeThatFits(size:

多线程更新ui

*爱你&永不变心* 提交于 2020-01-13 02:42:10
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) , ^{ ..... dispatch_async(dispatch_get_main_queue(), ^{ [self createData]; NSIndexSet *index = [NSIndexSet indexSetWithIndex:1]; [_tableView reloadSections:index withRowAnimation:UITableViewRowAnimationNone]; }); }); 回到主线程更新tableview,否则更新很不及时 来源: https://www.cnblogs.com/ios-wyh/p/4301780.html

Deriving UITableView sections from NSFetchedResultsController using “to many” relationship

允我心安 提交于 2020-01-13 02:14:30
问题 My Core Data model looks like this: article <--->> category Is it even remotely possible to use NSFetchedResultsController to produce a UITableView that looks something like this? Category 1 - Article A - Article B - Article C Category 2 - Article A - Article D - Article E - Article F Category 3 - Article B - Article C Specifically, I'm interested in the (edge?) case where each UITableView section has a unique title (eg, "Category 1", "Category 2"), but the same object can exist in multiple

Tableview scrolling bounces back and hides the bottom cells

社会主义新天地 提交于 2020-01-12 18:49:57
问题 I have a view that is shown under a navigation controller. The view contains one subview at the top portion and a table view at the bottom. The table might have rows that extend beyond the visible height based on data. When I have rows that are below the last visible row, if I scroll the view up, it bounces back, it does not stay there. Is there a way to make it stay? I tried making the parent view a scroll view and that did not help. My view is from a XIB. 回答1: Sounds like the size of your

UITableViewCell dequeueReusableCellWithIdentifier with custom initializer

落花浮王杯 提交于 2020-01-12 18:44:53
问题 I'm using [UITableView registerClass: forReuseIdentifier:] and [UITableView dequeueReusableCellWithIdentifier:] in order to queue and dequeue UITableViewCells. For example, in viewDidLoad: [self.storeTableView registerClass:[StoreLineGraphCell class] forCellReuseIdentifier:@"StoreLineGraphCellIdentifier"]; And in cellForRowAtIndexPath: StoreLineGraphCell *cell = (StoreLineGraphCell*)[self.storeTableView dequeueReusableCellWithIdentifier:@"StoreLineGraphCellIdentifier"]; In doing this, the

UITableViewCell dequeueReusableCellWithIdentifier with custom initializer

最后都变了- 提交于 2020-01-12 18:44:24
问题 I'm using [UITableView registerClass: forReuseIdentifier:] and [UITableView dequeueReusableCellWithIdentifier:] in order to queue and dequeue UITableViewCells. For example, in viewDidLoad: [self.storeTableView registerClass:[StoreLineGraphCell class] forCellReuseIdentifier:@"StoreLineGraphCellIdentifier"]; And in cellForRowAtIndexPath: StoreLineGraphCell *cell = (StoreLineGraphCell*)[self.storeTableView dequeueReusableCellWithIdentifier:@"StoreLineGraphCellIdentifier"]; In doing this, the

How to increase the label and cell size on clicking a button in a TableViewCell.

这一生的挚爱 提交于 2020-01-12 15:58:31
问题 I want to expand the cell size after clicking a seeMoreBtn on cell. The label and cells have varying length, but their is a constraint in size of label. When a status is too big, I added a seeMoreBtn, after clicking on see more the remaining text will be shown below, then how to increase the label and cell size. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; { NSString *text = [items objectAtIndex:[indexPath row]]; CGSize constraint =