0

Hi I have this code here.

- (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;
}

What I want is:

  1. To change the height of the UITableView cell so I can fit more things under the textLabel. (Currently, when I use the previous code to increase the height of the UITableView cell, each cell goes from big to small in different sizes).

  2. To show under the textLabel.text a detailedTextLabel of something else under it.

How would I do that?

I tried:

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

But it doesn't show up.

Flanfl
  • 516
  • 8
  • 29

1 Answers1

0

You can create new UItableview cell with the dimensions as per your requirements. Later

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

In this way you can create the tableview cell as per your requirements. I hope it will help.

Jason Sturges
  • 15,855
  • 14
  • 59
  • 80
Bharath
  • 161
  • 1
  • 3
  • 13