I'm using tableview with custom cell contains label and sender(button) , I have data on that tableview and when I make a search i got match results on the label only the sender(button) always match the first field on that table view before the search operation,and when i press that button the button toke an action with the first object in tableview before the search operation not the searched item.What I'm asking is how to make the search results match the custom cell content in label and the sender status in the same time ,I'm using swift 2.0 x code 7.1 ...
Thanks
Related
I have a custom table view cell that's the first cell in my table view, in which I have a textfield I'm trying to make function like a search feature.
I want the data in the remainder of the table view to update as the user types. I have the search cell's textField set up via .addTarget to trigger EditingChanged so every time the user types something new into the textField it will show the updated results. But it seems that calling self.tableView.reloadData() triggers EditingDidEnd and hides the keyboard, after each letter.
Via addTarget to the Search Cell's UITextField, I have a function searchBarEditingChanged(searchTextField: UITextField) where after self.tableView.reloadData() I call searchTextField.becomeFirstResponder()
How can I get around this?
I was considering using a search controller earlier but I didn't like that you have to pull down to make the search bar visible
edit:
tried using this instead
let sectionsToReload = IndexSet(1...sectionHeaders.count)
self.tableView.reloadSections(sectionsToReload, with: .none)
but it crashes on reloadSections: 2017-05-22 15:37:21.600257 MYAPP[565:89501] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.6.22/UITableView.m:1284
Keep the textfield and the result in two different sections, on search reload only result section. This should work
Use the UISearchBar—this is what it is for.
view.endEditing(false) in the UITextFieldDelegate method.
I have a view based NSOutlineView with some NSTextFields on one of it's columns.
To be able to edit any of these fields I have to click on them twice..first to select the row then to another click to select the text field itself and be able to edit it's contents.
The requirement was to be able to select the text fields using a single click. So in the outlineview's delegate i implemented the "outlineViewSelectionDidChange" like this:
func outlineViewSelectionDidChange(notification: NSNotification) {
let selected:NSInteger = settingsTable.selectedRow
let selectedRow = settingsTable.viewAtColumn(1, row: selected, makeIfNecessary: false)
let field = selectedRow.settingTextField as NSTextField
field.becomeFirstResponder()
}
where settingsTable is an outlet to my NSOutlineView
This works as needed: When I click on any of the text fields inside the OutlineView the current row is selected and the textfield can be edited without the additional click
The problem is that after I clicked on any of the text fields, when I try to expand/collapse the content, I get this error:
Row -1 out of row range [0-4] for rowViewAtRow:createIfNeeded:
Which is caused by the "viewAtColumn" method.
Is there an alternative to the "viewAtColumn" method or another way to get a specific NSTableCellView view using it's row and column?
Using a cell based NSOutlineView is not possible due to layout requirements outside my control.
I have a table view with a search bar. When I put some text in the search bar & search data I display different rows under different sections. I have enabled UIGestureRecognizer on the section header to collapse the rows. Once user tap on the section header I set the data objects to nil leading to number of rows returned for those sections as 0.
After the I call the following piece of code to refresh my search table view. It all works fine with exception that I can see "No Results" on the screen just below my collapsed sections. This works fine in non-search mode - collapsing the sections does not display "No Results" message there.
[self.searchController.searchResultsTableView reloadData];
I could see a private property _noResultsLabel & a _searchDisplayControllerFlags option as noResultsMessageAutoDisplay (set to 1) inside class UISearchDisplayController. Not able to reset them.
Any idea on this?
Actually i used the pickerView for display My database value containing Name, SSN, Research Area etc. Now I need to search in each component of pickerview, like Name,SSN using SearchBar is it Possible?
If I understand you right, you want to filter the rows of the components when the searchtext changed.
You can have a NSArray for each component to populate it with: In – searchBar:textDidChange: you can check which entries in your arrays fit to the search text and add it to a array, that you will use to fill the picker. Don't forget to either call [aPickerView reloadAllComponents] or [aPickerView reloadComponent:i], this will tell the picker to draw itself again.
i have tried to set up a uitableview cell to be given a tag however i am not sure how to get the cell to become tagged on user input (uibutton) and then the code required to retrieve the multiple items or single item tagged.
Well, without understanding exactly what you plan to do, indexPath points to the selected cell.
If you try to keep object references you could move all information you need to an instance variable type NSArray/NSDictionary from cellForRowAtIndexPath.