Post

Replies

Boosts

Views

Activity

Reply to How to open a view
I have opened a new thread. I have been searching and trying things but still, I do not understand your sketch solution. Are you sure this is macOS and storyboards? It looks very new to me and I do not know how to learn.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’21
Reply to How to open a view
These are some of the things I tried: var controller: NSWindowController? @IBAction func loadSecondFromMenu(_ sender: NSButton) { let storyboard: NSStoryboard = NSStoryboard(name: "Main", bundle: nil) let myViewController = storyboard.instantiateController(withIdentifier: "SecondView") as? SecondViewController //self.view.window?.contentViewController = myViewController //error: Value of type 'AppDelegate' has no member 'view'         //controller?.contentViewController = myViewController //no error, and it does not open any window }
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’21
Reply to Animate sizeToFit
I want to animate (using any method) the change of the label's text in a macOS app. With the code I provide, the change occurs when I click the button. I see no animation and no delay. import Cocoa class ViewController: NSViewController {     @IBOutlet weak var label1: NSTextField!     override func viewDidLoad() {         super.viewDidLoad()     }     @IBAction func button2(_ sender: NSButton) {         NSAnimationContext.runAnimationGroup({ (context) in             context.duration = 4.0             label1.stringValue = "long, long text"             label1.animator().sizeToFit()         })     } }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21