Dialogue D'Ouverture De Fichier
Comment puis-je permettre à mon utilisateur à télécharger une photo et réglez l'image d'une Image bien
- (IBAction)chooseFile:(id)sender {
int i; //Loop counter.
//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:YES];
//Display the dialog. If the OK button was pressed,
//process the files.
if ( [openDlg runModalForDirectory:nil file:nil] == NSOKButton )
{
//Get an array containing the full filenames of all
//files and directories selected.
NSArray* files = [openDlg filenames];
//Loop through all the files and process them.
for( i = 0; i < [files count]; i++ )
{
NSString* fileName = [files objectAtIndex:i];
//Do something with the filename
[customButtonImg setImage:[NSImage imageNamed:fileName]];
}
}
}
- runModalForDirectory:fichier:types: est obsolète dans OS X v10.6. Vous pouvez utiliser runModal à la place. Vous pouvez définir le chemin d'accès à l'aide setDirectoryURL:, et vous pouvez définir les types de fichiers à l'aide de setAllowedFileTypes:.
Vous devez vous connecter pour publier un commentaire.
Suivre ce, il pourrait être vous guider...