帮助模式文本输入新表项

问题描述:

首先让我开始说我对iPhone很新,所以我为我的无知道歉。帮助模式文本输入新表项

我有一个UITableView,我想添加新的项目。当按下添加按钮时,我想要一个模式屏幕向上滑动,在那里用户键入新项目的文本。

我已经从苹果公司的Table View Programming Guide for iPhone读书,和他们有按说我想要做什么的例子:

- (void)addItem:sender { 
// To add an item, display a modal view with a text field. 
if (itemInputController == nil) { 
    itemInputController = [[ItemInputController alloc] init]; 
} 
// Use a navigation controller to provide a customizable navigation bar with Cancel and Done buttons. 
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:itemInputController]; 
[[self navigationController] presentModalViewController:navigationController animated:YES]; 
[navigationController release]; 

}

但是他们没有解释itemInputController是随时随地的。据我可以确定它应该给我一个单一文本字段的模态视图,以及一个导航栏,其中包含取消和保存。我是否应该在Interface Builder中自己创建这个视图?还是我需要导入某种标准的东西?任何人都可以帮我解密这个,或者让我看看另一种方法来解决这个问题吗?

ItemInputController将是你需要添加到你的项目的UIViewController的衍生物。

您需要创建一个新的UIViewController子类,然后在IB中构建接口 - see here,以获得有关构建UIViewControllers的讨论。