Modalで開いたViewControllerからフォルダ選択パネルを呼び出すと、ViewControllerの下に表示されて、パネルが使えません。
Swift3
1//viewControllerの呼び出し 2let next = storyboard?.instantiateController(withIdentifier: "ViewController2") 3self.presentViewControllerAsModalWindow(next! as! NSViewController)
Swift3
1//呼び出したviewControllerからフォルダ選択パネルを開く 2 let openPanel :NSOpenPanel = NSOpenPanel() 3 openPanel.canChooseFiles = false 4 openPanel.canChooseDirectories = true 5 openPanel.allowsMultipleSelection = false 6 openPanel.message = "フォルダを選択してください" 7 openPanel.begin(completionHandler: { (num) -> Void in 8 if num == NSModalResponseOK { 9 for fileURL in openPanel.urls { 10 let filePath :String! = fileURL.path 11 let serverUrl :String! = filePath.removingPercentEncoding 12 print( serverUrl!) 13 } 14 } else if num == NSModalResponseCancel { 15 print("Canceled") 16 } 17 }) 18
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/26 01:34