Posts

Post not yet marked as solved
5 Replies
Open Library > Container View. If you use that, it creates that View Controller. In any case, I tried both ways with the same result.
Post not yet marked as solved
5 Replies
Here is an example with macOS:
Post not yet marked as solved
5 Replies
When you say "5. you can keep the content layout and frame layout ON", what do you mean?
Post marked as solved
6 Replies
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.
Post marked as solved
6 Replies
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 }
Post marked as solved
6 Replies
I have a window controller and two views. With my code, I open view1. I try to open view2 with code. I do not understand your code. It gives me error.
Post marked as solved
2 Replies
That is just fantastic! I have been hours searching and trying things and you solved in a minute!. Thank you!
Post marked as solved
5 Replies
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()         })     } }
Post marked as solved
5 Replies
This works very well. Thank you! .cursor: NSCursor.pointingHand
Post marked as solved
5 Replies
I did not notice that I had the wrong Outlet. It seems that only happens with macOS. in iOS I did not had that problem. Thank you! Do you know how to change the cursor on hover the link?
Post marked as solved
2 Replies
Sorry, I meant window size. (I do not see how to edit the question and correct that error) Thank you for your answer.
Post not yet marked as solved
2 Replies
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
Post not yet marked as solved
8 Replies
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.
Post not yet marked as solved
8 Replies
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 } }
Post not yet marked as solved
8 Replies
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() } }