nsindexpath

Tableview button selection wrong after search

断了今生、忘了曾经 提交于 2019-12-25 05:47:05
问题 I have a UIButton in the UITableViewCell . When a UIButton is tapped, I'm saving the tapped button tag in the array. So when I search within the UITableView using the UISearchController , I'm getting the desired output, but the selected button is selected within the wrong cell. Pic 1 - Button selected and before search pic 2 - After the search In the pic 1, I have selected the button that belongs to "room 1", but after the search, as you can see in the pic 2, the output is correct, but the

Table view cell background goes white when deleting a cell - iOS

别来无恙 提交于 2019-12-23 18:30:51
问题 I have an iOS app with a UITableView , I have noticed that the cell background colour flashes white when the user selects the Delete button. In the editActionsForRowAtIndexPath method, I have created two cell buttons: Edit and Delete . The first button's style is set to UITableViewRowActionStyleNormal . however the second button's style is set to UITableViewRowActionStyleDestructive - I have noticed that this issue only occurs when then style is set to destructive. Does anyone know why this

How to reset the tableview cells accessorytype to none on a click of a button?

﹥>﹥吖頭↗ 提交于 2019-12-23 09:59:36
问题 I am trying to code a reset button, so that when I click on that button all the tableview cells' accessory type get set to none . I have a clear concept of how to do it, but I am pretty new to iPhone development so I just need help with what methods to call. The steps I think I need to take: I am iterating through all the rows using a for loop - so I am counting the number of cells (successfully done). My problem is, I have no clue how to check for each of those rows/cells if the accessory

tableView.cellForRowAtIndexPath(indexPath) return nil

邮差的信 提交于 2019-12-23 09:33:46
问题 I got a validation function that loop through my table view, the problem is that it return nil cell at some point. for var section = 0; section < self.tableView.numberOfSections(); ++section { for var row = 0; row < self.tableView.numberOfRowsInSection(section); ++row { var indexPath = NSIndexPath(forRow: row, inSection: section) if section > 0 { let cell = tableView.cellForRowAtIndexPath(indexPath) as! MyCell // cell is nil when self.tableView.numberOfRowsInSection(section) return 3 for row

Check whether cell at indexPath is visible on screen UICollectionView

与世无争的帅哥 提交于 2019-12-23 07:27:37
问题 I have a CollectionView which displays images to the user. I download these in the background, and when the download is complete I call the following func to update the collectionViewCell and display the image. func handlePhotoDownloadCompletion(notification : NSNotification) { let userInfo:Dictionary<String,String!> = notification.userInfo as! Dictionary<String,String!> let id = userInfo["id"] let index = users_cities.indexOf({$0.id == id}) if index != nil { let indexPath = NSIndexPath

using swipe gesture to delete row on tableview

孤人 提交于 2019-12-22 23:03:15
问题 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:

How to compare two NSIndexPaths?

时光总嘲笑我的痴心妄想 提交于 2019-12-21 06:47:06
问题 I'm looking for a way to test if to index paths are equal, and by equal I mean equal on every level? I tried compare: but it seems not to work, I always get true when compared with NSOrderedSame even if the indexes are definitely not the same. 回答1: Almost all Objective-C objects can be compared using the isEqual: method. So, to test equality, you just need [itemCategoryIndexPath isEqual:indexPath] , and you're good to go. Now, this works because NSObject implements isEqual: , so all objects

How to check if IndexPath is valid?

时光怂恿深爱的人放手 提交于 2019-12-21 04:50:06
问题 Prior to swift 3, i used to use for example: let path = self.tableView.indexPathForSelectedRow if (path != NSNotFound) { //do something } But now, since i use IndexPath class in swift3, i'm looking for the equivalent for the path != NSNotFound check. Xcode8.3.1 compiler error: "Binary operator '!=' cannot be applied to operands of type 'IndexPath' and 'Int'" 回答1: Semantically, to consider an indexPath invalid , you need something to check for such as a table view or a collection view. Usually

Is there a way to automatically scroll to the bottom of a UICollectionView

吃可爱长大的小学妹 提交于 2019-12-21 02:59:32
问题 So I'm currently working on a project that has a button that adds cells to a UICollectionView and then needs to automatically scroll to the last cell (i.e. the bottom of the UICollectionView). I've found the method scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UICollectionViewScrollPosition)scrollPosition animated:(BOOL)animated But now I'm getting stuck at trying to find the indexPath of the last object in the CollectionView. The problem seems to lie in that I've been

isEqual doesn't always work for NSIndexPath? What can I use in its place?

梦想与她 提交于 2019-12-20 09:48:09
问题 I've got some code that relies on comparing two NSIndexPaths and executing different code based on their equality or lack thereof (using -isEqual). Most of the time it works properly, but sometimes it doesn't. I've used the debugger console to test the two indexpaths during code execution, and they look identical to me. Here's the code: - (BOOL)selectedStreetIsSameAsLastSelectedStreet { return [self.indexPathOfSelectedStreet isEqual:self.previousObject.indexPathOfSelectedStreet]; } Here's the