我是iOS应用程序开发的新手,我在UItableview上需要帮助.因为我用json数据填充表视图.我也使用Customized Tableviewcell.我没有在"lbluid"上获得所选单元格的"huid"值."lbluid"根据滚动显示"huid"的值,因为我将向上滚动它将显示UITableview的最上面可见单元格的"huid"值,如果我向下滚动它将显示last的"huid"值从下来可见细胞.
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableCell";
SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];;
}
NSUInteger row = [indexPath row];
cell.lbl4.text = [hudid objectAtIndex:row];
lbluid.text=cell.lbl4.text;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
Simpletablecell
是定制的UITableViewCell
.
And*_*law 11
您可能必须实现该方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
每次选择一行时调用,并在该方法内部调用:
Simpletablecell *cell = (Simpletablecell *)[tableView cellForRowAtIndexPath:indexpath];
lbluid.text = cell.lbl4.text;
Run Code Online (Sandbox Code Playgroud)
方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
被称为表视图正在加载要显示的单元格,这就是为什么lbluid.text
只在滚动表视图时才更改.
归档时间: |
|
查看次数: |
9521 次 |
最近记录: |