我正在开发一个测试应用程序,用户可以在其中插入容器的名称,然后从预制列表中添加项目。
基本上我的应用程序有3个UITableView:一个带有容器列表(#1),一个带有详细信息视图,其中包含容器(#2)保存的项目列表,以及一个包含所有容器列表的表可用项目(#3)。
我想做类似于IOS处理播放列表的方式:在主表(#1)上,用户按下“添加”按钮。出现UIAlertView,询问容器的名称。一旦用户输入了名称并按下“保存”按钮,应用程序就会直接进入UITable(#3),允许用户选择项目,而无需转到表格(#2)。
我认为这是一项非常简单的任务,但我无法实现它。
是的,有人可以帮帮我吗? 谢谢!编辑:我正在添加一些代码以明确说明。
当用户触摸“添加”按钮时,将以这种方式创建UIAlertView:
- (IBAction)addNewContainer:(id)sender {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"New Container"
message:@"Enter the name of the container:"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Save", nil];
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
[alertView show];
}
我想我应该在这里加载UITable(#3),但我不知道如何。我省略了核心数据中的创建和保存代码。
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
// If user clicked Save
if (buttonIndex == 1) {
// Create a new container in the CoreData
// Store the name of the container
UITextField *textField =[alertView textFieldAtIndex:0];
newContainerName.name = textField.text;
// Save item into the core data
// Reload the table with the new entry
[self readDataForTable];
}
}