Skip to content

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

@JeanBarreiros

Description

@JeanBarreiros

##- 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()
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions