nsindexpath

Weird behavior of UITableView method “indexPathForRowAtPoint:”

空扰寡人 提交于 2019-12-10 18:15:42
问题 As show in the following code, when the tableview is stretched (never scrolled up), the NSLog(@"tap is not on the tableview cell") will always be called ( as i thought the indexPath will always be nil ). But when i tap the avatar in the section header with section number greater than 2, the NSLog does not get called. It is weird, anyone know what's going on here? -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { ... UITapGestureRecognizer *tapGesture =

Get the IndexPath from inside a UITableViewCell subclass in Swift

只愿长相守 提交于 2019-12-10 12:29:12
问题 I have a custom UITableViewCell subclass and its associated xib. I have a UILabel and a UIButton in this cell and I have wired the touch up inside action of the button to the subclass. What I need is when that button in the cell is tapped, to get the indexpath of the cell which has that button. And maybe send it back to the view controller via a delegate or something. Since I'm inside a UITableViewCell subclass, I can't use a solution like this because I don't have a reference to the

indexpath.row is starting from 1 instead of 0

随声附和 提交于 2019-12-10 03:48:51
问题 i am facing a strance issue with a uitableview. sometime when my table's datasource/numberofrowsinsection has 3 values, cellforowatindexpath starts from 0-1 instead of 0-0. can someone help me out finding the possible reasons for this issue to happen. even tried printing the logs but the logs were shown for 0 -1 and 0 -2 but not for 0 -0. That means it is not getting called for the first row i.e 0 -0. 回答1: tableView:cellForRowAtIndexPath: is called as needed to display a cell, if a cell is

iOS: reload single cell of UICollectionView

橙三吉。 提交于 2019-12-09 02:56:37
问题 I am trying to follow the following post on reload a cell in a UICollectionView: UICollectionView update a single cell I know that I ultimately want something that looks like this: [self.collectionView reloadItemsAtIndexPaths:??]; But I don't know how to find and pass the indexPath of a particular cell. Can anyone provide any pointers? I have an NSMutableArray that contains all the cell information (imageViews that are generated in each cell). Ideally, what I'd like to do is pass the index of

tableView:cellForRowAtIndexPath called with nil indexPath after deleting item

陌路散爱 提交于 2019-12-08 14:46:55
问题 I have a rather vanilla UITableView managed by an NSFetchedResultsController to display all instances of a given Core Data entity. When the user deletes an entry in the table view by swiping over it, tableView:cellForRowAtIndexPath: eventually gets called on my UITableViewController with a nil indexPath . Since I had not expected it to be called with a nil indexPath , the app crashes. I can work around the crash by checking for that nil value and then returning an empty cell. This seems to

using swipe gesture to delete row on tableview

ぐ巨炮叔叔 提交于 2019-12-06 12:56:55
I am trying to bypass the red button delete (editingstyledelete) by setting up a gesture of swipe and then using IBAction to call a delete of the row that the swipe was performed in. The app crashes and I get a error of : NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0] - (IBAction)deleteSwipe:(id)sender{ [self deleteRow:self.tableView forCell:sender]; } -(void) deleteRow:(UITableView *)tableView forCell:(UITableViewCell *)bCell{ NSIndexPath *indexPath = [tableView indexPathForCell:bCell]; [tableView

Assertion Failure for UITableView selectRowAtIndexPath

為{幸葍}努か 提交于 2019-12-06 01:59:28
问题 I feel like this is an issue that requires special attention... my Google-fu is pretty good but I haven't been able to get anything useful. This is the simplest thing, and yet I can't seem to figure out what the problem is with it. I have a UITableView. It's a subview that my VC calls _form. I'm using it for styling purposes, not really to display data. It has 2 cells. On a certain event, I'm trying to select a different cell, using selectRowAtIndexPath:animated:scrollPosition. When I do this

How to get indexPath in a tableview from a button action in a cell?

依然范特西╮ 提交于 2019-12-06 00:31:52
问题 I have a tableview with two actions in it, for the first on i use the delegate didSelectRowAtIndexPath, for the second one i would like to use an action on a button on my cell to do something else. My problem is that i don't succeed to get the indexpath ? What is the best practice to do that. 回答1: If you have added the button to the cell as, [cell.contentView addSubview:button]; then, you can get the index path as, - (void)onButtonTapped:(UIButton *)button { UITableViewCell *cell =

switch that checks NSIndexPath's row and section

一个人想着一个人 提交于 2019-12-05 15:02:35
问题 I would like to set a switch statement that checks for a value if NSIndexPath . NSIndexPath is a class and it consists(among other things) of section and row ( indexPath.row, indexPath.section ) this is how I would formulate an if statement to check for a row and a section at the same time: if indexPath.section==0 && indexPath.row == 0{ //do work } What is swift switch translation for this? 回答1: One way (this works because NSIndexPaths themselves are equatable): switch indexPath { case

UICollectionView indexPathsForVisibleItems don't update new visible cells

时间秒杀一切 提交于 2019-12-04 19:41:27
问题 I have a ViewController with a CollectionView inside. When the view loads, the visible cells (9 cells) are shown correctly. When I scroll down, I want to load the visible items in the collectionview with loadImagesForOnscreenRows by calling the indexPathsForVisibleItems for partnerCollectionView. But when loadImagesForOnscreenRows the indexPathsForVisibleItems has allways the first 9 cells in it, even when cells 10 to 18 should be visible on the screen. The code I use is: #import