apasccon / searchtextfield Goto Github PK
View Code? Open in Web Editor NEWUITextField subclass with autocompletion suggestions list
License: MIT License
UITextField subclass with autocompletion suggestions list
License: MIT License
Is it possible to scroll the list of result and loads more?
Hi !
I have an issue with a SearchTextField.
My ViewController contains 2 IBOutlets:
When I press return when editing the first textField, I want the SearchTextField to become the first responder.
Here is my code:
if textField == mailTextField {
guard (mailTextField.text?.isValidEmail) == true else {
self.mailTextField.resignFirstResponder()
displayAlert(title: "Erreur", message: "L'adresse e-mail saisie ne semble pas valide")
return false
}
if school == nil {
self.schoolTextField.becomeFirstResponder()
} else {
self.mailTextField.resignFirstResponder()
}
} else if textField == schoolTextField {
self.schoolTextField.resignFirstResponder()
}
return true
}
So, when self.schoolTextField.becomeFirstResponder()
is called, this SearchTextField should become the first responder and begin editing.
I debugged and put a few prints. What happens is that the SearchTextField actually becomes the first responder (didBeginEditing
is called), but then resignFirstResponder() is called on it (not by anything in my VC, I removed everything to make sure of that). And then didEndEditing
is called on it.
In viewDidAppear
, if I put self.schoolTextField.becomeFirstResponder()
, it works perfectly ...
Also, if the SearchTextField is the first responder and then in textFieldShouldReturn
, I put self.mailTextField.becomeFirstResponder()
, it also works perfectly.
Apparently, the problem appears when having a standard UITextField as the first reponder and calling becomeFirstResponder()
on the SearchTextField.
Thanks for your help.
Is there a way to get filtered results?
In the itemSelectionHandler, I get position and item. But the position is as per the filtered list & not the original list. Here filtered list means the list which is formed after the user enters a character on the textfield and original list means the list of items supplied to the textfield for filtering.
Please help with the above issue.
It would be nice to import this as a framework with Carthage, because this is a good, regularly updated project and not everyone is using CocoaPods or likes manually integrating it.
Is there anyway to suggest as soon as @ is pressed after some string.
I want to suggest some email domains
self.inputField.filterStrings(["@gmail.com", "@hotmail.com"])
Can you make init
method of struct SearchTextFieldTheme
public, so anyone be able to create theme?
I downloaded the example project, and the country and acronym suggestions are not showing at all.
Only the inline suggestions are working. Maybe you messed the working part when you added the inline feature
Your project is really cool, I would really like to use it, so if you could please look into it.
Thanks in advance
first of all I thank you for that library it is a must have one. However, I have two issues with the library and they are as follows:
1st:
the suggestions table appear below the keyboard... but since the text field is nearly in the lower middle I prefer to show the table above the textField
2nd:
since I want the user to see the contents while typing I shift the textField view upwards... and it remains there until a choice from the suggestions table is Made.. the shifted view is reset to its original place behind the keyboard
3rd:
I know I only said 2, but can I have the option to resize the suggestion table width (not by resizing the textField itself)
One Last Comment: in the inline Mode: How can I accept the text without writing all of it
Your library is exactly what I need, however, is there a way to specify a custom table cell to be used as a search result? I want to customize the UI of the result a bit more than what is standard (more than just title, subtitle, image, etc.)
Is there a way to adjust the auto-complete suggestion list? I tried setting the size when I create the object with CGRect but it didn't work.
Hi
i have a problem with this textfield and keyboard handling
here i used a popular keyboard handling library but next and back button with two SearchTextFileds doesn't work
https://github.com/hackiftekhar/IQKeyboardManager
Currently, it's 'contain with
' searching. How can I change searching like 'a%'
?
Hi,
do you know if it's possible to add highlight (set pattern search bold in result list) on all occurrence of the pattern in each line string ?
example :
Regards,
S0r4
If I programmatically set the text on the text field, I am finding that the filtered list of matching results appear below the text field.
Is there a way to stop the list appearing when text is set programmatically?
ps love the control - and great work.
Hi,
I have application written in objective C, Can I use this subclass? I succeed to install it with CocoaPods into my project.
Thanks
Hey great framework here. I was testing the version you released yesterday. The dropdown with options does not seem to appear anymore. I implemented the simple example and also pulled down and ran your example project and no dice. The new feature "show the first matched result as placeholder (inline mode)" works great though.
In SearchTextFieldTheme we can't set custom font
For example when I use UIFont(name: "BNazanin", size: 10)! in init of SearchTextFieldTheme the tableview does not appear for suggestion
to reproduce:
opened new Xcode project
installed pod ver 1.0.10
code in view controller:
import UIKit
import SearchTextField
class ViewController: UIViewController {
@IBOutlet weak var mySearchTextField: SearchTextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Set the array of strings you want to suggest
mySearchTextField.filterStrings(["Red", "Blue", "Yellow"])
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
I have set print(item.title) when itemSelectionHandler get a call. but It's not print anything.
It work well if user click on suggestion tableview.
How can I fix it?.
Hello guys and thanks for your work...
I need to doesn't´t show the keyboard ontap, so only display the list... I try it delegating
extension X: UITextFieldDelegate {
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
return false
}
but doesn't works, just no appear nothing, no list (startvisible = true)
Any idea? Thanks!
How to change the placeholder property textColor of the placeholder if it is as fileprivate, this requires it to change the color of the field when I make field validations.
Suggestion list labels are single line. How do I make them multiline?
Is this possible?
Thanks for the great work.
itemSelectionHandler not call when I search text in textfield second time.
I tried debug in didSelectRowAt
and it told itemSelectionHandler is nil.
But It work for first time. Why??
I have a TableView with multiple rows and when I have your control in one of the rows and the suggestions come up it displays under the other rows thus making it not viewable. Do you have any suggestions to fix this. I have tried to bring the subview to the front but that does not work and I also tried setting the zPosition of the control higher than others and it still seems to not work.
Is that possible to change the search criteria?
I am using the subtitle to store some data i need when an item is selected. But i want to hide or show this data, as the user wants. Is there a way to do this at this moment?
It would be great to be able to make the list only activate when a certain character is typed, say the "@" character. I realize this is a bit of a deviation from the original goal of the code.
Hi,
Has anyone by any chance , had seen errors for the SearchTextField.swift errors.
When i drag to project, it gives me syntax errors of the file. ANy help would be really appreciated.
had modify the font size to 18 by using. "emailTextField.theme.font = UIFont.systemFont(ofSize: 18)". The suggestion character which consists in my emailtextfield still remain the default size while other character become 18.
Hi, is there a way to change the height of the search tableview? So that i can put it in a tableviewcell and it is contained by the cell height?
I want the list of countries to appear from right to left.
How would /i go about to do that?
thanks
If I am typing with the tableview showing, the first filtered result will be chosen and put into the textfield if I hit return key. However, if I click the textfield again without typing and hit the return key. Since there are no filtered results, the following method will produce empty string and the existing content of the textfield will be cleared.
open func textFieldDidEndEditingOnExit() {
self.text = filteredResults.first?.title
}
Simple search with the distro that came after Pod install does not work (Xcode 8.3.3 (8E3004b) :
...
Installing SearchTextField (1.1.4)
**
// Connect your IBOutlet...
@IBOutlet weak var mySearchTextField: SearchTextField!
// Set the array of strings you want to suggest
mySearchTextField.filterStrings(["Red", "Blue", "Yellow"])
**
The only way I could make this work was by copying the class from the example project directly into my project, under Pods/SeachTextField.
I see that the latest version is 1.1.6, but 'pod install' downloads 1.1.4, not sure why.
Hi,
actually this is a good component and it's very needed. good job. but when I used it in my application I used it to Seach in contact list and it's working fine as I mentioned in First image, BUT when I'm trying to Seach on another name it's not working as I mentioned in Second image. So can I use this to search in more one like in my application I'm trying to add users to to send mail to them so I need to add for ex 3 users. please advise and thanks for your support
Looks like you are now giving the selected item and index instead of the item array and index, but you haven't updated the readme.
:)
The first time I use the searchTextField, the proposals are displayed nicely
But the second time I display the searchTF, the proposals appear, and then disappear right away before I have time to select an entry.
Maybe an issue with userStoppedTypingHandler
?
This didn't happen in release 1.0.4, then I upgraded to 1.0.9 and the issue appeared.
Thanks !
In View Controller :
viewDidLoad()
{
self.ClientList.itemSelectionHandler = {item in
let title = item.title
print("Title Name of List = "+title)
self.ClientList.text=title
self.view.endEditing(true)
}
self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action:
Selector("dismissKeyboard")))
}
func dismissKeyboard()
{
ClientList.resignFirstResponder()
self.view.endEditing(true)
}
The Green bar stays visible which indicates that its not working
I have put SearchTextField in a UIScrollVeiw. but the problem is when scroll view scrolling FilterItems frame not changing. it works when I reset text in scrollViewDidScroll.
func scrollViewDidScroll(_ scrollView: UIScrollView) {
acronymTextField.text = acronymTextField.text // hack for move filter screen with textfield when scrolling
}
I have been playing with your code, which works fantastic by the way.
I really want my users to choose from a list, but I want them to be able to override if they really need to, and filter quickly. So, I load up a large list of options and use startVisible=true and all is grand.
However, if they type a few things and then erase back to blank, your current implementation does not reload the list.
Just needed to make 1 small change to make this work:
if text!.isEmpty {
clearResults()
tableView?.reloadData()
self.placeholderLabel?.text = ""
}
Change to:
if text!.isEmpty {
clearResults()
tableView?.reloadData()
filter(true)
self.placeholderLabel?.text = ""
}
I'm not sure if this creates other problems, but it seems to work for me!
Are there any plans to update to swift 3 for Xcode 8 support??
My popup dialog will be overlay by Keyboard.
Do you know how to avoid this make the user easily input?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.