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

Keep search bar visible after displaying placeholder #32

Open
douglas-srs opened this issue Apr 18, 2018 · 1 comment
Open

Keep search bar visible after displaying placeholder #32

douglas-srs opened this issue Apr 18, 2018 · 1 comment
Labels

Comments

@douglas-srs
Copy link

douglas-srs commented Apr 18, 2018

I have a search bar in my tableview which refreshes the content as the user types but if the search query is not found the "NoResultsPlaceholder" is shown and the search bar is automatically hidden, is there a way to make the placeholder show below the search bar?

My search bar is added to the table with this: self.tableView.tableHeaderView = UISearchBar()

@douglas-srs
Copy link
Author

douglas-srs commented Apr 18, 2018

I managed to preserve the headerView with my search bar by extending the TableView class

class SWTableView: TableView {

    private static var customTheme: PlaceholdersProvider {
        var style = PlaceholderStyle()
        
        style.shouldShowTableViewHeader = true
        
        let loading = Placeholder(data: .loading, style: style, key: .loadingKey)
        
        let error = Placeholder(data: .error, style: style, key: .errorKey)
        
        let noResults = Placeholder(data: .noResults, style: style, key: .noResultsKey)
        
        let noConnection = Placeholder(data: .noConnection, style: style, key: .noConnectionKey)
        
        let placeholdersProvider = PlaceholdersProvider(loading: loading, error: error,
                                                        noResults: noResults, noConnection: noConnection)
        
        return placeholdersProvider
    }
    
    override func customSetup() {
        placeholdersProvider = SWTableView.customTheme
    }


}

But now the placeholder content is half visible because the keyboard is visible, is there anyway to make the placeholder move up when the keyboard is visible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants