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

Action button is not visible, but tapping on the white space is printing logs. #19

Closed
junweimah opened this issue Jan 3, 2018 · 9 comments
Labels

Comments

@junweimah
Copy link

Hi,

I played around the example project and found that the placeholder has a button "try again", and user can tap that.

However in my project, there is no action button, but I can tap on the white space below the subtitle and the log is printing "Placeholder action button tapped"

How and where do I set the action button to visible?

Thanks

@HamzaGhazouani
Copy link
Owner

Hi @junweimah, the background color of the action button, by default, is the tintColor of the TableView, just change it. Or if you would like to customize it you can use PlaceholderStyle

@junweimah
Copy link
Author

How do I use PlaceholderStyle?

In other question, you guided me to this code :

//test a custom placeholder
            let provider: PlaceholdersProvider = .default
            var noConnectionData: PlaceholderData = .noConnection
            noConnectionData.title = "My custom title"
            noConnectionData.subtitle = "Please check your connection !!! "
            
            let noConnectionPlaceholder = Placeholder(data: noConnectionData, style: PlaceholderStyle(), key: .noConnectionKey)
            provider.add(placeholders: noConnectionPlaceholder)
            self.tvBug.placeholdersProvider = provider

Now in let noConnectionPlaceholder = Placeholder(data: noConnectionData, style: PlaceholderStyle(), key: .noConnectionKey), for PlaceholderStyle() I have to cuztomize right?

What do I need to do to change the text and background color of the action button?

@HamzaGhazouani
Copy link
Owner

So to customize the style you can do like that :

//test a custom placeholder
let provider: PlaceholdersProvider = .default
var noConnectionStyle = PlaceholderStyle()
noConnectionStyle.actionBackgroundColor = .red
...
var noConnectionData: PlaceholderData = .noConnection
noConnectionData.title = "My custom title"
noConnectionData.subtitle = "Please check your connection !!! "
    
let noConnectionPlaceholder = Placeholder(data: noConnectionData, noConnectionStyle: , key: .noConnectionKey)
provider.add(placeholders: noConnectionPlaceholder)
self.tvBug.placeholdersProvider = provider

@junweimah
Copy link
Author

junweimah commented Jan 4, 2018

Wow. it works! Thanks

For the action button tap function

func view(_ view: Any, actionButtonTappedFor placeholder: Placeholder) {
        //do something here
        print("this is placeholder tapped !!! ")
    }

Why is this not printed out?

Only "Placeholder action button tapped" bring printed out, and that can be traced back to PlaceholderTableViewCell.swift :

@IBAction func sendPlaceholderAction(_ sender: Any) {
        onActionButtonTap?()
        print("Placeholder action button tapped")
    }

@HamzaGhazouani
Copy link
Owner

You are welcome :)
It's not printed out because your controller is not conform to the protocol PlaceholderDelegate:

extension ViewController: PlaceholderDelegate {
    
    func view(_ view: Any, actionButtonTappedFor placeholder: Placeholder) {
        print(placeholder.key.value)
        placeholderTableView?.showDefault()
    }
}

@junweimah
Copy link
Author

My vc actually have this right now

class BugTabTableViewController: UITableViewController, IndicatorInfoProvider, PlaceholderDelegate{

func view(_ view: Any, actionButtonTappedFor placeholder: Placeholder) {
      //do something here
      print("this is in big tv vc placeholder tapped !!! ")
      print("this is key value \(placeholder.key.value)")
//        self.tvBug.showDefault()
  }

However this is not printed out

@HamzaGhazouani
Copy link
Owner

Hi @junweimah,

I think you missed to set the placeholderDelegate to self:
tvBug.placeholderDelegate = self

@junweimah
Copy link
Author

WOW.

Thanks. It works!

Thank you so much. Best git library owner ever. Answered all my questions. Fast reply. Good job

@HamzaGhazouani
Copy link
Owner

My pleasure, thank you for your contribution and for your kind words :)

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