gpt4 book ai didi

xcode - 不激活全屏模式的 Kiosk 风格 - OS X

转载 作者:搜寻专家 更新时间:2023-11-01 05:36:31 26 4
gpt4 key购买 nike

我试图隐藏屏幕顶部的停靠栏和菜单/聚光灯栏,基本上进入我的 Cocoa OS X 应用程序的信息亭模式。但是,我不想激活全屏模式。我希望应用程序正常运行,但只是隐藏桌面上的停靠栏和菜单/聚光灯区域以阻止用户使用它们。我尝试了多种选择,但似乎无法正常工作。

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

似乎此代码的大多数实现都需要进入全屏或在 Objective C 中。有没有一种方法可以在 Swift 中执行此操作而无需进入全屏模式?

  • 更新 - 我知道怎么做了!我可以使用 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)

    }
    }
    }

最佳答案

以下是您要查找的内容吗?

swift 3:

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

swift 2:

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

}

(注释掉代码中的所有其他内容,或者至少注释掉此处包含的代码)。

关于xcode - 不激活全屏模式的 Kiosk 风格 - OS X,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38130545/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com