在 box api 中有一个按钮来创建一个文件夹。但我不知道如何修改按钮让我创建一个包含子文件夹的文件夹。
我想做什么:
当您单击“添加文件夹”按钮时,您会收到一个 NSAlert,它会询问您要为其命名的名称。必须修改此警报,使其具有多个文本栏。在第一个栏中,您可以填写新文件夹的名称。其他(3)您可以留空不创建子文件夹,或填写名称以创建子文件夹。
这可能吗?我会很感激你能给我的每一个帮助或提示!
一些代码:
#pragma mark - Folder creation - (void)addFolderButtonClicked:(id)sender { UIAlertView *folderNamePrompt = [[UIAlertView alloc] initWithTitle:@"Add Folder" message:@"Name:" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
folderNamePrompt.alertViewStyle = UIAlertViewStylePlainTextInput;
[folderNamePrompt show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{ if (buttonIndex == alertView.firstOtherButtonIndex) { UITextField *nameField = [alertView textFieldAtIndex:0]; BoxFolderBlock success = ^(BoxFolder *folder) { [self fetchFolderItemsWithFolderID:self.folderID name:self.navigationItem.title]; };
BoxAPIJSONFailureBlock failure = ^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSDictionary *JSONDictionary)
{
NSLog(@"folder create failed with error code: %i", response.statusCode);
if (response.statusCode == 409)
{
dispatch_sync(dispatch_get_main_queue(), ^{
UIAlertView *conflictAlert = [[UIAlertView alloc] initWithTitle:@"Name conflict" message:[NSString stringWithFormat:@"A folder already exists with the name %@.\n\nNew name:", nameField.text] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
conflictAlert.alertViewStyle = UIAlertViewStylePlainTextInput;
[conflictAlert show];
});
}
};
BoxFoldersRequestBuilder *builder = [[BoxFoldersRequestBuilder alloc] init];
builder.name = nameField.text;
builder.parentID = self.folderID;
[[BoxSDK sharedSDK].foldersManager createFolderWithRequestBuilder:builder success:success failure:failure];
}