nsindexpath

Objective-C: Instance Variable in Category

被刻印的时光 ゝ 提交于 2019-11-27 13:17:03
I am just asking whether it was possible to add an instance variable via a category. My special problem is, that I need to add an NSIndexPath property to an ASIHTTPRequest object but I don't wanna subclass the ASIHTTPRequest as a matter of principle. Do I have any kind of alternative? Thanks for your answers, Christian albertamg A category can not declare additional instance variables but since OS X 10.6 and iOS 3.1 you can work around this with associative references . You can use associative references to simulate the addition of object instance variables to an existing class. Using

tableView section headers disappear SWIFT

十年热恋 提交于 2019-11-27 11:57:37
问题 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.item vs NSIndexpath.row

蹲街弑〆低调 提交于 2019-11-27 06:56:46
Does anyone know the difference between NSIndexpath.row and NSIndexpath.item ? Specifically, which one do I use in: -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; Okay, nobody has given a good answer here. Inside NSIndexPath, the indexes are stored in a simple c array called "_indexes" defined as NSUInteger* and the length of the array is stored in "_length" defined as NSUInteger. The accessor "section" is an alias to "_indexes[0]" and both "item" and "row" are aliases to "_indexes[1]". Thus the two are functionally identical. In terms of

indexPathForRowAtPoint returns nil only for first cell in a uitableview

风格不统一 提交于 2019-11-27 06:50:43
问题 I have a UIButton inside of a custom UITableViewCell that removes the cell when the button is pressed. In order to get the indexPath of the cell the button is in, I'm calling indexPathForRowAtPoint : in a method called when the button is pressed as follows: -(void)buttonPressed:(UIButton *)sender{ CGPoint btnPosition = [sender convertPoint:CGPointZero toView:self.tableView]; NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:btnPosition]; if (indexPath != nil) { //remove the cell

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

。_饼干妹妹 提交于 2019-11-27 00:37:28
问题 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

How to get indexPath when image inside cell tapped

邮差的信 提交于 2019-11-26 21:59:27
问题 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) //

Objective-C: Instance Variable in Category

纵饮孤独 提交于 2019-11-26 16:17:13
问题 I am just asking whether it was possible to add an instance variable via a category. My special problem is, that I need to add an NSIndexPath property to an ASIHTTPRequest object but I don't wanna subclass the ASIHTTPRequest as a matter of principle. Do I have any kind of alternative? Thanks for your answers, Christian 回答1: A category can not declare additional instance variables but since OS X 10.6 and iOS 3.1 you can work around this with associative references. You can use associative

NSIndexpath.item vs NSIndexpath.row

梦想与她 提交于 2019-11-26 12:24:21
问题 Does anyone know the difference between NSIndexpath.row and NSIndexpath.item ? Specifically, which one do I use in: -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; 回答1: Okay, nobody has given a good answer here. Inside NSIndexPath, the indexes are stored in a simple c array called "_indexes" defined as NSUInteger* and the length of the array is stored in "_length" defined as NSUInteger. The accessor "section" is an alias to "_indexes[0]"

swift: how to get the indexpath.row when a button in a cell is tapped?

a 夏天 提交于 2019-11-26 01:18:53
问题 I have a tableview with buttons and I want to use the indexpath.row when one of them is tapped. This is what I currently have, but it always is 0 var point = Int() func buttonPressed(sender: AnyObject) { let pointInTable: CGPoint = sender.convertPoint(sender.bounds.origin, toView: self.tableView) let cellIndexPath = self.tableView.indexPathForRowAtPoint(pointInTable) println(cellIndexPath) point = cellIndexPath!.row println(point) } 回答1: giorashc almost had it with his answer, but he