Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I propose fix to avoid null failure on iPhone 5 #27

Open
JeanBarreiros opened this issue Sep 24, 2018 · 0 comments
Open

I propose fix to avoid null failure on iPhone 5 #27

JeanBarreiros opened this issue Sep 24, 2018 · 0 comments

Comments

@JeanBarreiros
Copy link

##- 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()
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant