1

これにより、1 つのファイルのみを選択できます

- (void)Choose:(UIButton *)sender {
    NSArray *arry = [[NSArray alloc] initWithObjects:@"public.data", nil];
    UIDocumentPickerViewController *pickDoc = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:arry inMode:UIDocumentPickerModeImport];
    pickDoc.delegate = self;
    pickDoc.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentViewController:pickDoc animated:YES completion:nil];
}

-(void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {



    if (controller.documentPickerMode == UIDocumentPickerModeImport) {
        NSString *alertMessage = [NSString stringWithFormat:@"Successfully imported %@", [url lastPathComponent]];
        dispatch_async(dispatch_get_main_queue(), ^{
            UIAlertController *alertController = [UIAlertController
                                                  alertControllerWithTitle:@"Import"
                                                  message:alertMessage
                                                  preferredStyle:UIAlertControllerStyleAlert];
            [alertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:nil]];
            [self presentViewController:alertController animated:YES completion:nil];
        });
    }
}
4

0 に答える 0