【发布时间】:2012-06-13 11:15:12
【问题描述】:
您好,我这里有这段代码。
- (void)viewDidLoad
{
[super viewDidLoad];
jsonURL = [NSURL URLWithString:@"http://oo.mu/json2.php"];
jsonData = [[NSString alloc] initWithContentsOfURL:jsonURL usedEncoding:nil error:nil];
self.jsonArray = [jsonData JSONValue];
// Do any additional setup after loading the view, typically from a nib.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [jsonArray count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [indexPath row] * 20;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [[self.jsonArray objectAtIndex:indexPath.row] objectForKey:@"Name"];
return cell;
}
我想要的是:
更改
UITableView单元格的高度,以便我可以容纳更多textLabel下的东西。 (目前,当我使用以前的 增加UITableView单元格高度的代码,每个单元格 从大到小,大小不一)。在
textLabel.text下显示detailedTextLabel在它下面还有别的东西。
我该怎么做?
我试过了:
cell.textLabel.text = [[self.jsonArray objectAtIndex:indexPath.row] objectForKey:@"Name"];
cell.detailTextLabel.text = [[self.jsonArray objectAtIndex:indexPath.row] objectForKey:@"Street"];
cell.detailTextLabel.text = [[self.jsonArray objectAtIndex:indexPath.row] objectForKey:@"City"];
但它没有显示出来。
【问题讨论】:
标签: uitableview height cell detailtextlabel