【发布时间】:2015-04-14 07:22:01
【问题描述】:
在我的应用程序中,我正在动态创建一个带有 2 个控件的表格视图单元格,一个是UILabel,用于显示我从 Web 服务接收的标题,另一个是 aUITextField。这个UITextField 将接受用户输入。
现在所有的字段名称和字段类型都是从网络服务接收的,所以我不知道每次都会来哪个字段?
那么,当用户在字段中输入相应的值时,我如何保存它们并识别它们属于哪个标题?
我尝试了this 选项,但它仅适用于静态UITableView(他们已经知道哪些字段属于值)
我将得到一系列字段,例如“身高”、“血压”等。 我的用户界面是这样的
在我的代码部分
.m file is
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1; //count of section
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [fieldName count]; //dynamic field name array count
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"cell";
cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[testCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyIdentifier];
}
NSString *uppercaseString = [[fieldName objectAtIndex:indexPath.row] uppercaseString];
cell.title.text=uppercaseString;//filed name
return cell;
}
从这里我如何获取输入文本值并保存它???
【问题讨论】:
-
您想节省任何操作或点击的价值吗??
-
使用数据源保存值。
-
是的,当我点击按钮时,我需要保存值
-
正如 iphonic 所说,您有一个数据源。使用它!
-
代码或设计中的 UITextField 和保存按钮在哪里???
标签: ios objective-c iphone uitableview tableviewcell