nsindexpath

Convert NSInteger to NSIndexpath

不想你离开。 提交于 2019-11-28 20:06:24
Basically I am storing an index of an array in a NSInteger. I now need it as an NSIndexpath, I'm struggling to see and find a way to convert my NSInteger to NSIndexpath so I can reuse it. For an int index : NSIndexPath *path = [NSIndexPath indexPathWithIndex:index]; Creates Index of the item in node 0 to point to as per the reference . To use the indexPath in a UITableView , the more appropriate method is NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:section]; If you need a NSIndexPath for a UITableView , you can use indexPathForRow:inSection: ( reference ). Index paths passed

tableView section headers disappear SWIFT

混江龙づ霸主 提交于 2019-11-28 19:08:45
I have a tableView set up so that when a cell is touched, it expands in height to reveal more information. The tableView has 5 sections. I have a bug: when a cell expands, all headersCells below that cell go invisible. The console outputs the following: "[31233:564745] no index path for table cell being reused" In my storyboard I have 2 custom cells : "myCell" for the data bearing cells, and "headerCell" for the headers. func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { let thisGoal : GoalModel = goalArray[indexPath.section][indexPath.row] if self

how to access from UICollectionViewCell the indexPath of the Cell in UICollectionView

孤街浪徒 提交于 2019-11-28 18:21:37
i want to animate the UICollectionViewCell when action is called. i have done UICollectionViewCell in Interface Builder , the UICollectionView also. Now i want to get the correct indexPath at my actionBtnAddToCard method. thats the way i try it now (method in ProduktViewCell.m): - (IBAction)actionAddToCart:(id)sender { XLog(@""); // see this line NSIndexPath *indexPath = ??** how can i access the correct indexPath**??; SortimentViewController *svc = [[SortimentViewController alloc] initWithNibName:@"SortimentViewController_iPad" bundle:[NSBundle mainBundle]]; [svc.collectionViewProdukte

NSFetchedResultsController prepend a row or section

此生再无相见时 提交于 2019-11-28 15:53:03
问题 I have a UITableView populated with a standard NSFetchedResultsController. However I'd like to prepend a row or a section (row preferably but either would works fine really.) The only way I can possibly see doing this right now is to rewrite all the NSIndexPath's manually when dealing with the section/rows dealing with the data from NSFetchedResultsController to trick it into seeing section at index 0 and starting with row at index 0. This however seems like a really bad idea that would

How to get indexPath when image inside cell tapped

烈酒焚心 提交于 2019-11-28 14:41:07
I would like to implement feature that if profileImage tapped in tableviewCell, segue to detailView. I add tapGesture but I still can't figure out how to get indexPath to pass data. I tried like this but app will crash. override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "detailSegue" { let next: DetailViewController = segue.destination as! DetailViewController // pattern1 let indexPath = tableView.indexPath(for: sender as! CustomTableViewCell) // pattern2 let indexPath = tableView.indexPathForSelectedRow! as NSIndexPath next.data = datas[indexPath.row] }

Creating slow scrolling to indexPath in UICollectionView

╄→гoц情女王★ 提交于 2019-11-28 08:18:34
I'm working on a project where I'm using a UICollectionView to create an 'image ticker' where I'm advertising a series of logos. The collectionView is one item high and twelve items long, and shows two to three items at a time (depending on size of the logos visible). I would like to make a slow automatic scrolling animation from the first item to the last, and then repeat. Has anyone been able to make this work? I can get the scrolling working using [myCollection scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:(myImages.count -1) inSection:0] atScrollPosition

How can I keep track of the index path of a button in a table view cell?

半世苍凉 提交于 2019-11-28 04:43:53
I have a table view where each cell has a button accessory view. The table is managed by a fetched results controller and is frequently reordered. I want to be able to press one of the buttons and obtain the index path of that button's table view cell. I've been trying to get this working for days by storing the row of the button in its tag, but when the table gets reordered, the row becomes incorrect and I keep failing at reordering the tags correctly. Any new ideas on how to keep track of the button's cell's index path? I have created one Method for getting indexPath, Hope this will help you

Get Selected index of UITableView

戏子无情 提交于 2019-11-28 04:01:54
I want to have selected index for UITableView . I have written following code: NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0]; [tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionTop animated:YES]; This always work for 1st item. I want to have selected index in indexPathForRow. Please help. Thanks. NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow]; Get current selected row. May be helpful if you have only one section. - (NSUInteger)currentSellectedRowIndex { NSIndexPath *selectedIndexPath = [self.tableView

Given model object, how to find index path in NSTreeController?

元气小坏坏 提交于 2019-11-28 00:14:39
问题 Given model objects that NSTreeController represents, how do you find their index paths in the tree and subsequently select them? This seems to be a blindingly obvious problem, but I can't seem to find any reference to it. Any ideas? 回答1: There's no "easy" way, you have to walk the tree nodes and find a matching index path, something like: Objective-C: Category @implementation NSTreeController (Additions) - (NSIndexPath*)indexPathOfObject:(id)anObject { return [self indexPathOfObject:anObject

Get Selected index of UITableView

烂漫一生 提交于 2019-11-27 19:15:36
问题 I want to have selected index for UITableView . I have written following code: NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0]; [tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionTop animated:YES]; This always work for 1st item. I want to have selected index in indexPathForRow. Please help. Thanks. 回答1: NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow]; 回答2: Get current selected row. May be helpful if you have only one section