0

I used NSCollectionView in my application. In certain condition i want to hide and Unhide the NSCollectionView. But it will not hide the NSCollectionView.

I used the following code

 @IBOutlet weak var thumbnailView: NSCollectionView!
 func applicationDidFinishLaunching(aNotification: NSNotification) {
    thumbnailView.hidden = true
    NSThread.sleepForTimeInterval(5)
    thumbnailView.hidden = false
}

Note: Sleep the thread just for demonstration purpose

Also Hiding the NSScrollView is not working.

EDIT: I perform same code on Button Touch up Inside event i get the same result. It does not hide my CollectionView.

@IBAction func ButtonnISClick(sender: AnyObject) {
        thumbnailView.hidden = true
        NSThread.sleepForTimeInterval(5)
        thumbnailView.hidden = false

    }
Rizwan Shaikh
  • 2,824
  • 2
  • 27
  • 49

1 Answers1

0

Here are things that are wrong with your code (mostly because you did not provide enough information in your question):

  1. Use lowercase strings when naming variables (so change ThumbnailView to thumbnailView;
  2. I don't know where are you writing this code. Is it NSWindowController, NSViewController or NSWindow subclass? Depending on the location, you should write 2nd to 4th lines in different methods (either windowDidLoad(), viewDidLoad() or awakeFromNib()

Update: Given your code is in application did finish launching and you are sleeping in that method, you won't see any changes, since the window of your app is presented only after the method has returned (i.e. all code has been executed). I suggest you to move this code into a subclass of either NSWindowController's windowDidLoad (I'm not sure about that one) or NSViewController's viewDidAppear: method.

Eimantas
  • 48,927
  • 17
  • 132
  • 168