objective c - Using same Storyboard Popover from multiple anchors? -


i have popover created in storyboard displays list select from. there multiple buttons on view need pick lists looks have create exact same popover each button.

does know of way use same popover in storyboard?

with storyboards (and new , improved nsviewcontroller) it's easy create popover segues many different sources. image shows simplest of examples; popover text field changes depending on button pressed:

storyboard app running on top

the view controller popover subclassed add "name" variable, can add whatever object(s) wish bind in view.

the main view controller implements prepareforsegue function. depending on object sender, sets popovercontroller's "name" property different values.

here's code needed make example work:

//  viewcontroller.swift  import cocoa  class popovercontroller: nsviewcontroller { var name: string? }  class viewcontroller: nsviewcontroller {  override func prepareforsegue(segue: nsstoryboardsegue!, sender: anyobject!) {     if let popovercontroller: popovercontroller? = segue.destinationcontroller as? popovercontroller! {         if let button: nsbutton? = sender as? nsbutton! { switch (button!.title!) {             case "one": popovercontroller!.name = "first button"             case "two": popovercontroller!.name = "second button"             default: true } }     } }} 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -