0
안녕하세요.이 코드는 여기에 있습니다.UITableView 셀 높이를 동일하게 변경하는 방법 및 detailedTextLabel을 표시 하시겠습니까?
- (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;
}
내가 원하는 것은 :
그래서 나는
textLabel
에서 더 일을 맞출 수UITableView
셀의 높이를 변경합니다. (현재, 이전의 코드를 사용하여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"];
을하지만 표시되지 않습니다 :
나는 시도했다.