nsviewcontroller

Cocoa - Present NSViewController programmatically

試著忘記壹切 提交于 2020-06-01 13:38:11
问题 Generally, We can able to display next view controller from first view controller by having different kind of NSStoryboardSeque like Present, Show, Sheet etc., But, How we can achieve the same programmatically?. Comparing with UIViewController, presenting a view controller modally by presentViewController:animated: . Is there any same kind of approach for NSViewController? Thanks in advance. 回答1: The two different presentation types I use are: func presentViewControllerAsModalWindow(_

Cocoa - Present NSViewController programmatically

你说的曾经没有我的故事 提交于 2020-06-01 13:31:11
问题 Generally, We can able to display next view controller from first view controller by having different kind of NSStoryboardSeque like Present, Show, Sheet etc., But, How we can achieve the same programmatically?. Comparing with UIViewController, presenting a view controller modally by presentViewController:animated: . Is there any same kind of approach for NSViewController? Thanks in advance. 回答1: The two different presentation types I use are: func presentViewControllerAsModalWindow(_

How to close window (NSWindowController) by hitting the ESC key?

拟墨画扇 提交于 2020-02-23 08:01:39
问题 Issue I would like the user being able to close a window by hitting the ESC key but I can't get it to work in this specific case, hitting ESC triggers an error sound (the "no you can't do that" macOS bloop) and nothing happens. Context I'm making a subclass of NSWindowController which itself creates an instance of a subclass of NSViewController and sets it in a view. Both controllers have their own xib file. NSWindowController: final class MyWindowController: NSWindowController,

What is the correct subclass to link storyboard and swiftUI?

浪子不回头ぞ 提交于 2020-01-06 08:07:12
问题 I have created the subclass below to link my swiftui code to my storyboard. The goal is to have a vstack with text containers in it display inside a ContainerView. I am not sure if I am using the right class: NSViewController? I do not get any errors, but the code does not display how I want it to. Mostly, The swiftui does not display inside the window that shows up when I run the app. import SwiftUI class termu: NSViewController { override func viewDidLoad() { super.viewDidLoad() // Do view

Swift: Switch between NSViewController inside Container View / NSView

天涯浪子 提交于 2020-01-01 09:37:23
问题 I want to achieve a really simple task—changing the ViewController of a Container View by pressing a button: In my example the ViewController1 is embedded into the Container View using Interface Builder. By pressing the Button ViewController2 I want to change the view to the second ViewController. I’m confused because the Container View itself seems to be a NSView if I create an Outlet and as far as I know a NSView can’t contain a VC. Really appreciate your help! 回答1: Just note that in order

How to pass data between viewcontrollers

让人想犯罪 __ 提交于 2019-12-25 10:01:03
问题 I have a fairly complex application at this point, and feel as though the way I am handling data is not up to scratch. So I have started taking some steps towards making my app more MVC friendly. The first of which, I have gone from having inline parser methods in all of my ViewControllers to creating a dedicated parser class. Its not hard to call I just set up the class then call the initializer method I have made which I pass the data to for my request.. everything in my object class works

How to perform IBAction before dismiss sheetViewController from same UIButton?

最后都变了- 提交于 2019-12-25 06:45:28
问题 I am writing a Cocoa Mac app in Objective-C and using Storyboard for my UI. I have a "Confirm" button in my sheetViewController.m which I want to perform some action (save some settings) as well as dismiss the sheetViewController at the same time. They both use the sheetViewController.m as outlets. Unfortunately, with Storyboard, I can only pick one received action (IBAction) or dismissController. I want to perform the IBAction FIRST, before dismissing the sheet. How can I accomplish this?

Swapping views - NSWindowController and NSViewController(s)

做~自己de王妃 提交于 2019-12-24 07:38:01
问题 I'm very new in Mac OS programming. At the moment I'm trying to create simple measurement application which will have one window with the toolbar at the top and the appropriate view in the bottom. Clicking button in the toolbar should result in switching view below it - e.g. clicking on the "Connection" button will show with connection settings, "Measurements" will show current data from the device. The problem is - I don't know how to handle swapping views, maybe in other words - something I

Mac OSX Storyboard : communicate between NSViewController

别等时光非礼了梦想. 提交于 2019-12-24 05:29:25
问题 I use storyboard in a OS X cocoa application project with a SplitView controller and 2 others view controller LeftViewController and RightViewController. In the LeftViewController i have a tableView that display an array of name. The datasource and delegate of the tableview is the LeftViewController. In the RightViewController i just have a centered label that display the select name. I want to display in the right view the name selected in the left view. To configure the communication

Mac OSX Storyboard : communicate between NSViewController

蓝咒 提交于 2019-12-24 05:29:11
问题 I use storyboard in a OS X cocoa application project with a SplitView controller and 2 others view controller LeftViewController and RightViewController. In the LeftViewController i have a tableView that display an array of name. The datasource and delegate of the tableview is the LeftViewController. In the RightViewController i just have a centered label that display the select name. I want to display in the right view the name selected in the left view. To configure the communication