【发布时间】:2013-12-11 05:10:06
【问题描述】:
我有 viewcontroller .h .m 和 .xib,其中包含用于插入更新和删除的注册表单。
我还有其他包含显示 sqlite 数据的 uitableview 的 xib。我如何显示???
我编写了代码,但它在 viewcontroller 页面数组和 viewcontroller 中使用的其他控件上给出了错误。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [data count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [[data objectAtIndex:indexPath.row] valueForKey:@"name"];
cell.detailTextLabel.text = [[data objectAtIndex:indexPath.row] valueForKey:@"salary"];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
name.text = [[data objectAtIndex:indexPath.row] valueForKey:@"name"];
salary.text = [[data objectAtIndex:indexPath.row] valueForKey:@"salary"];
}
这里的数据是NSArray,在viewcontroller.h 文件中会出现错误
而且在didSelectRowAtIndexPath 方法name.text 和salary.text 中也会出错,因为它是viewcontroller 的文本字段。
我该如何解决?????
【问题讨论】:
标签: ios iphone objective-c sqlite uitableview