2012-06-09 2 views
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; 
} 

내가 원하는 것은 :

  1. 그래서 나는 textLabel에서 더 일을 맞출 수 UITableView 셀의 높이를 변경합니다. (현재, 이전의 코드를 사용하여 UITableView 셀의 높이를 늘리면 각 셀 은 다른 크기로 크게 이동합니다).

  2. 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"]; 

을하지만 표시되지 않습니다 :

나는 시도했다.

답변

0

귀하의 요구 사항에 따라 치수가 새 UItableview 셀을 만들 수 있습니다. 나중에

-(Uitableview) cellForIndexPath { 
    //add the customized Uitableviewcell. 
} 

이렇게하면 요구 사항에 따라 tableview 셀을 만들 수 있습니다. 나는 그것이 도움이되기를 바랍니다.

관련 문제