Answer the question
In order to leave comments, you need to log in
File upload via WebView swift 2.2 under os x?
Hello everyone, I am writing my first "application" under os x)))
Everything works fine except for one moment, the dialog box does not open when loading a file, I spent the whole day today looking for a solution - but so far to no avail (
Here is the entire "code" of my project:
override func viewDidLoad() {
super.viewDidLoad()
let easyTestUrl = NSURL(string: "https://example.com")
let easyTestUrlRequest = NSURLRequest(URL: easyTestUrl!, cachePolicy: NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData,timeoutInterval: 10.0)
EasyTest.mainFrame.loadRequest(easyTestUrlRequest);
// Do any additional setup after loading the view.
}
Answer the question
In order to leave comments, you need to log in
Connect delegate and use
- (void)webView:(WebView *)sender runOpenPanelForFileButtonWithResultListener:(id < WebOpenPanelResultListener >)resultListener
{
// Create the File Open Dialog class.
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
// Enable the selection of files in the dialog.
[openDlg setCanChooseFiles:YES];
// Enable the selection of directories in the dialog.
[openDlg setCanChooseDirectories:NO];
if ( [openDlg runModal] == NSOKButton )
{
NSArray* files = [[openDlg URLs]valueForKey:@"relativePath"];
[resultListener chooseFilenames:files];
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question