-5

I have a little problem with app and looking for the best solution. I want to create an popup window that have separate logic in other NSViewController.

The case is - I click on the button in my window and then other window appears with some NSTextField's and custom design. I'm considering what component is the best for my issue.

something like this:

my view

Thank you in advance for any help !

Double W
  • 1
  • 1
  • 2
  • `NSPanel` or create another window? Have you looked at the [Window Programming Guide](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/WinPanel/Introduction.html#//apple_ref/doc/uid/10000031i)? – Abizern Aug 02 '16 at 12:08
  • You could just link the button which should open the window to a viewcontroller by control dragging from the button to the the viewcontroller? – Eric Aug 02 '16 at 12:22

2 Answers2

2

If have done it with the following code:

let addMyPopover = NSPopover()

if let popOverController = aViewController(xyz: data) {
            popOverController.closeDelegate = self
            addMyPopover.behavior = .Transient
            addMyPopover.contentViewController = popOverController
            addMyPopover.contentSize = CGSizeMake(450, 380)
            addMyPopover.showRelativeToRect(addButton.bounds,    ofView: addPhaseButton, preferredEdge: NSRectEdge.MinY)
        }

extension MyController: closeViewDelegate {
    func closePopover(sender: AnyObject?) {
       addMyPopover.performClose(sender)
    }
} 

protocol closeViewDelegate: class {
   func closePopover(sender: AnyObject?)
}

aViewController is from type NSViewController

AM_
  • 111
  • 1
  • 5
  • It's not exactly what I need (see screenshot) – Double W Aug 02 '16 at 14:29
  • I thing thats the way Apple suggest to use: https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/OSXHIGuidelines/ControlsView.html#//apple_ref/doc/uid/20000957-CH52-SW1 – AM_ Aug 03 '16 at 06:43
0
@IBAction func showPopover(_ sender: NSButton) {
    let vcPopover = NSStoryboard(name: "Main", bundle: nil).instantiateController(withIdentifier: "viewControllerPop") as! NSViewController
    self.presentViewController(vcPopover, asPopoverRelativeTo : sender.bounds, of : sender, preferredEdge: .maxY, behavior: .transient)
}

enter image description here

Mannam Brahmam
  • 2,225
  • 2
  • 24
  • 36