MAC OSX學習(二)
實現視窗的跳轉:
1、建立一個新工程,取消勾選Use Storyboards如圖:
2、建立一個新的NSWindowController,勾選Also create XIB…如圖:
設定標題MainWindowController:
MainWindowController.m
self.window.title = @"主頁面";
3、刪除MainMenu.xib中的Window
4、AppDelegate中修改程式碼如下:
AppDelegate.h
#import <Cocoa/Cocoa.h>
#import "MainWindowController";
@interface AppDelegate : NSObject <NSApplicationDelegate>
/* 主視窗 */
@property(strong) MainWindowController *mainWindow;
@end
AppDelegate.m
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
_mainWindow = [[MainWindowController alloc]initWithWindowNibName:@"MainWindowController"];
//顯示在螢幕中心
[[_mainWindow window] center];
//當前視窗顯示
[_mainWindow.window orderFront:nil];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}
@end
5、執行效果如下:
6、建立第二個視窗SecondWindowController
SecondWindowController
self.window.title = @"第二個頁面";
7、MainWindowController點選顯示下一個頁面,呼叫主要程式碼:
self.secondWindow = [[ SecondWindowController alloc]initWithWindowNibName:@"SecondWindowController"];
//顯示下一個介面
[self.secondWindow.window orderFront:nil];
//關閉當前視窗
[self.window orderOut:nil];
8、SecondWindowController點選返回,呼叫主要程式碼:
//通過代理設定主視窗
AppDelegate *delegateAPP = [[NSApplication sharedApplication]delegate];
[self.window close];
[delegateAPP.mainWindows.window center];
[delegateAPP.mainWindows.window makeKeyAndOrderFront:nil];
demo地址:https://github.com/MisterZhouZhou/Mac-OSX-WindowChange
相關文章
- 遠端管理 Mac OSX 裝置Mac
- MAC OSX Docker安裝教程2018MacDocker
- Mac OSX網路診斷命令Mac
- Windows 10 美化 Mac OSX 實用教程WindowsMac
- EVE-NG 入門教程 (Mac OSX BIg Sur)Mac
- 最新 Mac 惡意軟體 OSX/CrescentCore 被發現Mac
- Mac OSX 10.12顯示通用中的任何來源Mac
- Working with Matplotlib on OSX
- Mac OSX系統homebrew update Fetching failed問題解決方案MacAI
- Docker-OSX:在Docker中執行你的蘋果Mac!Docker蘋果Mac
- Go學習【二】學習資料Go
- Golang 學習——interface 介面學習(二)Golang
- TypeScript 學習(二)TypeScript
- Kaldi學習(二)
- hdfs學習(二)
- MyBatis學習(二)MyBatis
- goblog 學習二Go
- docker學習(二)Docker
- springboot學習日誌(二)– thymeleaf學習Spring Boot
- Vue學習筆記(二)------axios學習Vue筆記iOS
- 機器學習-習題(二)機器學習
- 函式學習二函式
- 深入學習Redis(二)Redis
- semantic UI學習(二)UI
- 深度學習 DEEP LEARNING 學習筆記(二)深度學習筆記
- 高等數學學習筆記(二)筆記
- React 學習筆記【二】React筆記
- TensorFlow學習筆記(二)筆記
- vue學習筆記二Vue筆記
- lumen5.5學習(二)
- goLang學習筆記(二)Golang筆記
- RxJava2 學習(二)RxJava
- Vue全家桶學習(二)Vue
- Vue 學習記錄二Vue
- ANFIS學習筆記(二)筆記
- HTTP 學習瞭解(二)HTTP
- 字串函式學習二字串函式
- activiti學習筆記二筆記
- 考研學習總結(二)