Noo*_*oor 7 iphone uitableview ios ios5
我想在我的tableview中显示来自web的不同数据但是我没有得到如何在表的一个部分中的单独单元格中显示它们可以帮助我在一个单元格中显示
cell.textLabel.text=app.i_name;
Run Code Online (Sandbox Code Playgroud)
在第二个细胞中
cell.textLabel.text=app.i_phone;
Run Code Online (Sandbox Code Playgroud)
在第三个细胞中
cell.textLabel.text=app.i_hours;
Run Code Online (Sandbox Code Playgroud)
在第四个细胞中
cell.textLabel.text=app.i_address;
Run Code Online (Sandbox Code Playgroud)
在第五个细胞中
cell.textLabel.text=app.i_email;
Run Code Online (Sandbox Code Playgroud)
我索引行的单元格为
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Single Cell";
SingleCell *cell =(SingleCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
UIViewController *c = [[UIViewController alloc] initWithNibName:@"SingleCell" bundle:nil];
cell = (SingleCell *) c.view;
//[c release];
}
appDC * application = [dataArray objectAtIndex:[indexPath row]];
//cell.namelbl.text=application.application_name;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
试试这段代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Single Cell";
SingleCell *cell =(SingleCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
UIViewController *c = [[UIViewController alloc] initWithNibName:@"SingleCell" bundle:nil];
cell = (SingleCell *) c.view;
//[c release];
}
appDC * application = [dataArray objectAtIndex:[indexPath row]];
//cell.namelbl.text=application.application_name;
if (indexPath.row == 0)
{
cell.textLabel.text=application.i_name;
}
else if (indexPath.row == 1)
{
cell.textLabel.text = application.i_iphone;
}
else if (indexPath.row == 2)
{
cell.textLabel.text = application.i_hours;
}
else if (indexPath.row == 3)
{
cell.textLabel.text = application.i_address;
}
else
{
cell.textLabel.text = application.i_email;
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)
希望这个答案会有所帮助.干杯
| 归档时间: |
|
| 查看次数: |
1016 次 |
| 最近记录: |