Giter Site home page Giter Site logo

philippeboisney / modernsearchbar Goto Github PK

View Code? Open in Web Editor NEW
185.0 185.0 37.0 41.23 MB

The famous iOS search bar with auto completion feature implemented.

License: Other

Ruby 2.53% Swift 97.47%
autocomplete autocompletion ios search searchbar suggestions swift swift3 uisearchbar url

modernsearchbar's People

Contributors

philippeboisney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modernsearchbar's Issues

Using Firebase

Hi trying to use this with Firebase. I am using the withURL option but nothing shows when i search. The data is pulling from firebase.

Suggestions view does not shift when SearchBar shifts

I have a UISearchBar roughly in the middle of the page vertically. On clicking, it goes to the top of the screen. However, the SuggestionsListView of ModernSearchBar doesn't shift up and remains in its original position. Which section could be changed to update the position of the suggestions list if the the UISearchBar is moved? Thanks in advance!

image

Crash

Well i have tried using your great library, but unfortunately it's crash.

i found out you calling this method

private func updateSizeSuggestionsView(){
    var frame: CGRect = self.suggestionsView.frame // suggestionView is nil 

before setting up the suggestionView.
I have tried to download your example project and it's crash as well :-/

I propose fix to avoid null failure on iPhone 5

##- OBS 1

  • When compiling the application and generating the error below in the ModernSearchBar.swift file in the updateSizeSuggestionsView () method
    updateSizeSuggestionsView()
private func updateSizeSuggestionsView(){
    var frame: CGRect = self.suggestionsView.frame
    frame.size.height = self.getExactMaxHeightSuggestionsView(newHeight: self.suggestionsView.contentSize.height)

    UIView.animate(withDuration: 0.3) {
        self.suggestionsView.frame = frame
        self.suggestionsView.layoutIfNeeded()
        self.suggestionsView.sizeToFit()
    }
}
  • Corrigir assim: (veja que foi adicionado um if para evitar objeto nulo)
private func updateSizeSuggestionsView(){
    if(suggestionsView != nil){
        var frame: CGRect = self.suggestionsView.frame
        frame.size.height = self.getExactMaxHeightSuggestionsView(newHeight: self.suggestionsView.contentSize.height)

        UIView.animate(withDuration: 0.3) {
        self.suggestionsView.frame = frame
        self.suggestionsView.layoutIfNeeded()
        self.suggestionsView.sizeToFit()
        }
    }
}

##- OBS 1

  • When compiling the application and generating the error below in the ModernSearchBar.swift file in the updateSizeSuggestionsView () method
    clearCacheOfList()
private func clearCacheOfList(){
    ///Clearing cache
    for suggestionItem in self.suggestionListWithUrl {
        suggestionItem.imgCache = nil
    }
    ///Clearing cache
    for suggestionItem in self.suggestionListWithUrlFiltred {
        suggestionItem.imgCache = nil
    }

    self.suggestionsView.reloadData()
}
  • Corrigir assim: (veja que foi adicionado um if para evitar objeto nulo)
private func clearCacheOfList(){
    ///Clearing cache
    for suggestionItem in self.suggestionListWithUrl {
        suggestionItem.imgCache = nil
    }
    ///Clearing cache
    for suggestionItem in self.suggestionListWithUrlFiltred {
        suggestionItem.imgCache = nil
    }

    //Veja que foi adicionado um if para evitar objeto nulo
    if(suggestionsView != nil){
        self.suggestionsView.reloadData()
    }
}

Can't customize searchBar

Hi the searchBar seems not assuming the custom values or anything but i don't have any error or warning.
My code and storyboard:
screen shot 2018-04-19 at 13 56 23

My setup:
class MyViewController: ModernSearchBarDelegate{
@IBOutlet weak var searchBar: ModernSearchBar!

   override func viewDidLoad() {
        super.viewDidLoad()
        self.searchBar.delegateModernSearchBar = self
        var suggestionList = Array<String>()
        suggestionList.append("Onions")
        suggestionList.append("Celery")
        
        self.searchBar.setDatas(datas: suggestionList)
        
        //Modify shadows alpha
        self.searchBar.shadowView_alpha = 0.8
        
        //Modify the default icon of suggestionsView's rows
        self.searchBar.searchImage = ModernSearchBarIcon.Icon.none.image
        
        //Modify properties of the searchLabel
        self.searchBar.searchLabel_font = UIFont(name: "Avenir-Light", size: 30)
        self.searchBar.searchLabel_textColor = UIColor.red
        self.searchBar.searchLabel_backgroundColor = UIColor.black
        
        //Modify properties of the searchIcon
        self.searchBar.suggestionsView_searchIcon_height = 40
        self.searchBar.suggestionsView_searchIcon_width = 40
        self.searchBar.suggestionsView_searchIcon_isRound = false
        
        //Modify properties of suggestionsView
        ///Modify the max height of the suggestionsView
        self.searchBar.suggestionsView_maxHeight = 1000
        ///Modify properties of the suggestionsView
        self.searchBar.suggestionsView_backgroundColor = UIColor.brown
        self.searchBar.suggestionsView_contentViewColor = UIColor.yellow
        self.searchBar.suggestionsView_separatorStyle = .singleLine
        self.searchBar.suggestionsView_selectionStyle = UITableViewCellSelectionStyle.gray
        self.searchBar.suggestionsView_verticalSpaceWithSearchBar = 10
        self.searchBar.suggestionsView_spaceWithKeyboard = 20
    }

The result:
screen shot 2018-04-19 at 14 01 59

I can't figure out whats happening.

Thanks in advance

Swift 4.2 errors

There are many errors in Swift 4.2โ€ฆ Can you look at it? Thanks!
Here are the errors:

  • UITableViewCellSeparatorStyle has been renamed to UITableViewCell.SeparatorStyle
  • UITableViewCellSelectionStyle has been renamed to UITableViewCell.SelectionStyle
  • UITableViewAutomaticDimension has been renamed to UITableView.automaticDimension
  • UIKeyboardWillShow has been renamed to UIResponder.keyboardWillShowNotification
  • UIKeyboardWillHide has been renamed to UIResponder.keyboardWillHideNotification
  • UIKeyboardFrameEndUserInfoKey has been renamed to UIResponder.keyboardFrameEndUserInfoKey
  • UIApplicationDidReceiveMemoryWarning has been renamed to UIApplication.didReceiveMemoryWarningNotification
  • UITableViewCellStyle has been renamed to UITableViewCell.CellStyle

Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value

I have tried using this library - runs great on the emulator.

Tried pushing it to the phone and I get this:

Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value

This is inside the ModernSearchBarIcon.swift

private func getImageFromBundle(name: String) -> UIImage { let podBundle = Bundle(for: ModernSearchBarIcon.self) if let url = podBundle.url(forResource: "ModernSearchBar", withExtension: "bundle") { let bundle = Bundle(url: url) return UIImage(named: name, in: bundle, compatibleWith: nil)! } return UIImage() }

Gives out the error at "return UIImage(named: name, in: bundle, compatibleWith: nil)!
"

Any resolution??

How to close suggestion when i selected one ?

Hi,

This project is perfect for me but I have a little problem..

How to close suggestion list when i selected one ?
When I click on suggestion, I have my data, I do my treatment but the suggestion bar is always displayed.

Thx :)

Swift 2.3 Code

Can you provide the same code in swift 2.3 . I need to implement in swift 2.3

Better instalation section

Hey, your library is really interesting.

The only problem I found was the README.md, which has an incomplete Installation Section
I created this iOS Open source Readme Template so you can take a look on how to easily create a complete Installation Section
If you want, I can help you to organize the lib.

What are your thoughts? ๐Ÿ˜„

Adding ModernSearchBar to nav bar

I added the ModernSearchBar programmatically to the nav bar titleView. The suggestion view is not appearing when "setDatas" is set with suggestions. Is there any way to have suggestion view appear when search bar is in Nav bar or does it need to be in a separate view?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.