2016-06-30 2 views
2

화면 맨 위에 도크와 메뉴/스포트라이트 바를 숨기려하고 기본적으로 내 코코아 OS X 앱의 키오스크 모드로 들어갑니다. 그러나 전체 화면 모드를 활성화하고 싶지는 않습니다. 앱을 평소대로 실행하고 싶지만 바탕 화면의 도크와 메뉴/스포트라이트 영역을 숨겨서 사용자가 사용하지 못하도록하기 만하면됩니다. 나는 다양한 옵션을 시도해 왔지만 제대로 작동하지 않는 것 같습니다.전체 화면 모드를 활성화하지 않은 키오스크 스타일 - OS X

https://developer.apple.com/library/mac/technotes/KioskMode/Introduction/Introduction.html

전체 화면으로 갈 필요하거나 목적 C.에있는 전체 화면 모드로 전환하지 않고 스위프트에이 일을하는 방법이 있나요이 코드의 대부분의 구현처럼 보인다?

  • 업데이트 - 어떻게 해야할지 알아 냈습니다. NSMenu를 사용하여 메뉴를 숨길 수 있었지만 터미널에 액세스하여 도크를 숨겨야했습니다. 더 쉽고 깨끗한 방법이있을 수 있지만 찾을 수 없습니다. 이 솔루션이 도움이되기를 바랍니다.

    import Cocoa 
    
    @NSApplicationMain 
    class AppDelegate: NSObject, NSApplicationDelegate { 
    
        var datastring = NSString() 
    
    
    func applicationDidFinishLaunching(aNotification: NSNotification) { 
    
    let task = NSTask() 
    let pipe = NSPipe() 
    task.standardOutput = pipe 
    
    task.launchPath = "/bin/bash/" 
    task.arguments = ["defaults write com.apple.dock tilesize -int 1", "killall -Kill Dock"] 
    
    let file:NSFileHandle = pipe.fileHandleForReading 
    
    task.launch() 
    task.waitUntilExit() 
    
    let data = file.readDataToEndOfFile() 
    datastring = NSString(data: data, encoding: NSUTF8StringEncoding)! 
    
    // Insert code here to initialize your application 
    } 
    
    func applicationWillTerminate(aNotification: NSNotification) { 
    // Insert code here to tear down your application 
        } 
    
    override func awakeFromNib() { 
    
    NSMenu.setMenuBarVisible(false) 
    
    } 
        } 
    } 
    
+0

환경 설정에서 메뉴를 숨길 수 있습니다. 어쩌면 스크립트가 그것을 숨길 수 있습니다. –

+0

NSMenu에서 메뉴를 숨길 수 있었지만 여전히 독을 숨길 수는 없습니다. – cheesydoritosandkale

+0

이 명령은 도킹 설정을 변경하지만 명령에 숨기는 방법을 모르겠습니다. 기본값 쓰기 com.apple.dock autohide -bool true 기본값 쓰기 com.apple.dock autohide-delay -float 0 기본값 쓰기 com.apple.dock 자동 시간 수정 자 -float 0 (각 'defaults'앞에 줄 바꿈) –

답변

0

다음 중 어떤 것이 있습니까?

스위프트 3 : 2

func applicationWillFinishLaunching(_ notification: Notification) { 
    NSApp.presentationOptions = [.autoHideDock, .autoHideMenuBar] 
} 

스위프트 :

func applicationWillFinishLaunching(notification: NSNotification) { 
    NSApp.presentationOptions = [.AutoHideDock, .AutoHideMenuBar] 

} 

(당신이 여기에 포함 된 코드를 코드에서 다른 모든 주석, 또는 적어도).

+0

굉장 !! 고맙습니다!!!! – cheesydoritosandkale

0

나는 그것을 수행하는 방법을 알아 냈어! NSMenu를 사용하여 메뉴를 숨길 수 있었지만 터미널에 액세스하여 도크를 숨겨야했습니다. 더 쉽고 깨끗한 방법이있을 수 있지만 찾을 수 없습니다. 나는 이것이 다른 사람들이 해결책을 찾는데 도움이되기를 바랍니다.

import Cocoa 

    @NSApplicationMain 
    class AppDelegate: NSObject, NSApplicationDelegate { 

    var datastring = NSString() 


    func applicationDidFinishLaunching(aNotification: NSNotification) { 

    let task = NSTask() 
    let pipe = NSPipe() 
    task.standardOutput = pipe 

    task.launchPath = "/bin/bash/" 
    task.arguments = ["defaults write com.apple.dock tilesize -int 1", 
    "killall -Kill Dock"] 

let file:NSFileHandle = pipe.fileHandleForReading 

    task.launch() 
    task.waitUntilExit() 

    let data = file.readDataToEndOfFile() 
    datastring = NSString(data: data, encoding: NSUTF8StringEncoding)! 

    } 

    func applicationWillTerminate(aNotification: NSNotification) { 
    } 

override func awakeFromNib() { 

NSMenu.setMenuBarVisible(false) 

} 
    } 
} 
관련 문제