Post

Replies

Boosts

Views

Activity

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 }
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()         })     } }
Aug ’21
Reply to How to create a button in Preferences
What do you mean by pages (I have two pages) ? I have two View Controllers in storyboard and two files for the code: ViewController.swift and Preferences.swift. They are connected in the Identity inspector. Please show code that will be easier to explain. In a simplified version, there is no code yet. I just put a button on the View Controller - Preferences of the Storyboard
Jul ’20
Reply to I do not see the simulator
If I do not make subclass I think I should:var webView: WKWebView!If I do that the code works well to make a webview with code if I begin a new project. To repair the projects with the old code just write that new code does not seem to work. Even then I make Product > Clean Built Folder.
Jun ’20
Reply to I do not see the simulator
This code gives me the same problem:import Cocoa import WebKit class ViewController: NSViewController, WKNavigationDelegate { var webView: WKWebView! override func loadView() { webView = WKWebView() webView.navigationDelegate = self view = webView } override func viewDidLoad() { super.viewDidLoad() let url = URL(string: "https://www.apple.com")! webView.load(URLRequest(url: url)) webView.allowsBackForwardNavigationGestures = true } }
Jun ’20
Reply to I do not see the simulator
I have other macOS and iOS projects with the exact same code and still now they work well. I do not know why I cannot do any new one.Signing & Capabilities > Outgoing Connections (Client)ViewController.swift:import Cocoa import WebKit class ViewController: NSViewController { let webView = WKWebView() override func loadView() { self.view = webView if let url = URL(string: "https://www.apple.com") { let request = URLRequest(url: url) webView.load(request) } } override func viewDidLoad() { super.viewDidLoad() } }
Jun ’20