sirlink99 56 Practically a Master Poster

Hello,

I am working on a simple timer toolbar app in swift for macOS and I am experiencing a visual bug.

Basically, I should be able to add any number of timers to the main screen and they should stack on top of each other. Once the space is filled up in the window, a scroll bar appears allowing you to scroll through all the timers. My issue is that when I add the timers, they do not show all the time. I have a hunch it is either some refresh issue or some spacing issue.

The blank screen looks like this:
Screen_Shot_2017-07-18_at_10_45_21.png

The bug is visible here. Out of the 3 timers added only 2 show up with the empty space between the 2 timers being the location where the third timer should be: Screen_Shot_2017-07-18_at_10_49_06.png

The main scene is arranged like this: Screen_Shot_2017-07-18_at_10_52_12.png

Where the mainScreenView and the dynamicScrollView and the View are all set to 250px wide. The timer view itself is a separate view, but that is also 250 px wide.

The code that adds the timers to the window is as follows:

func updateList(){
        let documentView = NSView(frame: CGRect(x:0,y:0,width:250,height:max(360, AppDelegate.timekeeperArray.count*60)))
        documentView.autoresizesSubviews = true
        documentView.canDrawConcurrently = true

        var counter = 0
        for var i in AppDelegate.timekeeperArray{
            //let offset = CGFloat(counter * 50)
            //let button = NSButton(frame: CGRect(x:0, y:offset, width:150, height:50 ))
            dsvScrollView.contentView.addSubview(i.getPreview(index: counter))
            counter += 1;
        }
        dsvScrollView.documentView = documentView
        for var i in (dsvScrollView.documentView?.subviews)!{
            i.needsDisplay = true
            i.superview?.needsDisplay = true
            for var j in i.subviews{
                j.needsDisplay = true
            }
        }
        dsvScrollView.documentView?.needsDisplay = true
        dsvScrollView.superview?.needsDisplay = true
        dsvScrollView.needsDisplay = true
    }

I have tried resizing everything but the timer view in order to make more space for it, I have tried to disable all of the resize subview options in the settings. I have attempted set the needsDisplay to true in order to re-draw them, and I have also left it out and none of it fixed the issue.

I would appreciate any suggestions and help. If you require any more information then please let me know!

Thanks!

rproffitt commented: Interesting issue but I have no way to duplicate. +12