first mac app - push viewcontroller

无人久伴 提交于 2019-12-23 01:35:12

问题


I have a question, I do some iphone application and now I want to do a little mac application.

From a clean application I add a button on MainMenu xib, than I add a NSViewController to MainMenu (from IB) with one Action. I create a new NSViewController (FirstViewController) with a nib file and a button. Now I want only to create a function to push FirstController from MainMenu and a simple function to push MainMenu from FirstController.

something like this

ViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController: ViewController animated:YES];

How can I do it???


回答1:


I think you're trying to bring an iOS-style interface to MacOS X, and that won't work in many cases. The MacOS X user interface is very different from that of iOS.

iOS apps are limited to a single (and often small) window, and users generally do one thing at a time. The navigation interface standardizes the way that users drill down through different parts of a task so that the journey is predictable. The interface is very modal in the sense that the user is constantly navigating between different parts of the app, and user actions are often linked to the part of the app that's active.

The desktop, on the other hand, has plenty of screen space and allows multiple windows. Desktop apps should be modeless -- a user doesn't navigate through the app, but sees the whole thing laid out before him or her. As much as possible, the user should be able to perform any action at any time.

For these reasons, there is no navigation controller in Cocoa similar to Cocoa Touch's UINavigationController. If you can tell us more about the tasks that your two view controllers manage, perhaps someone here will help you think of ways to translate that better to the expected desktop experience.




回答2:


Here apple discusses the migrating iOS to OS X strategies. Your scenario is also discussed here:

For example, AppKit uses the NSBrowser class to manage the display of hierarchical information; in contrast, an iOS app would use navigation controllers.

And NSBrowser can be seen in use here with the output as shown in the attached image.



来源:https://stackoverflow.com/questions/6768142/first-mac-app-push-viewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!