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

.ignoreFirstSeparator and renderer customizations ignored on reloadData() #5

Open
fahlout opened this issue May 31, 2018 · 7 comments

Comments

@fahlout
Copy link

fahlout commented May 31, 2018

After calling reloadData() the initial customizations I have made like .ignoreFirstSeparator seem to be ignored as it shows the first separator again after reload. Same happens when adding customization to the renderer.

@EMart86
Copy link
Owner

EMart86 commented Jun 14, 2018

Hi @fahlout, sorry that it took that long! I've been working on that issue and fixed it. If you've any recommendations, i'll be glad to work on that. Best!

@fahlout
Copy link
Author

fahlout commented Jun 15, 2018

@EMart86 I just updated your library through cocoa pods for my project and am unfortunately still experiencing the same issue. Maybe I'm setting it up wrong. Could you send me some code as to how to set it up so I can compare with my code?

In my code this is how I'm setting it up:

func setupTickerView(_ tickerView: SwiftTickerView, dataSet: [String]) {
        let tickerProvider = TickerProvider()
        tickerProvider.content = dataSet
        tickerView.contentProvider = tickerProvider
        tickerView.viewProvider = self
        tickerView.separator = "..."
        tickerView.add(decorator: .ignoreFirstSeparator)
        tickerView.distanceBetweenNodes = 10
        tickerView.render = Renderer.rightToLeft
        tickerView.registerNodeView(UILabel.self, for: tickerLabelIdentifier)
        tickerView.tickerDelegate = self
    }

@EMart86
Copy link
Owner

EMart86 commented Jun 18, 2018

Your code runs perfectly fine in the example project i've provided with this pod. Are you supporting iOS 9 within your app? I've had struggles with ios 9 thats why i dropped it, but with the latest version 1.4.3 i'm supporting it again. Pls let me know if it helped. Best

@fahlout
Copy link
Author

fahlout commented Jun 19, 2018

I think I got it figured out now. I'm only supporting 10.2 or above so that wasn't the issue, but rather the way I coded the reloading part was not correct. The setup code above worked, but once I reloaded things were not working correctly.

The modifications I had to make were to add tickerView.reloadData() to the end of my setup function and when I want to reload I had to call the setup again with my new data set and set the index of my content provider back to 0 and call reloadData() again. I'm not sure why I have to setup the entire ticker view again every time I want to reload data, but that was the only way to get it to work for me. I was just setting the new content to the provider before and calling reloadData(). Here is my code for the reloading part:

func reloadTickerView(with alertDescriptions: [String]) {
    setupTickerView(tickerView, dataSet: alertDescriptions)
    guard let contentProvider = (tickerView.contentProvider as? TickerProvider) else { return }
    contentProvider.updateContent()
    tickerView.reloadData()
}

class TickerProvider: SwiftTickerProviderProtocol {
    
    ...
    
    func updateContent() {
        index = 0
    }
}

@EMart86
Copy link
Owner

EMart86 commented Jun 21, 2018

Hi, you actually don't need to resetup the whole ticker view. I've looked up in my sample project at https://github.com/EMart86/SwiftTickerView/blob/master/Example/SwiftTickerView/ViewController.swift at line number 62.

@IBAction func updateContentAndReload(_ sender: Any) { tickerContentProvider.updateContent() tickerView.reloadData() }

This is all i do, when reloading the content

@ChetanPote93
Copy link

hello I am facing issue is that when I passing array first time there is no gap and after navigating from one screen to another and came back again.

@EMart86
Copy link
Owner

EMart86 commented Jan 2, 2024

@ChetanPote93 Could you please provide my your setup code?
Especially with the tickerView.distanceBetweenNodes part.
Or maybe use tickerView.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

3 participants