views:

27

answers:

1
-  (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return [topics count];
    }

    - (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier {

        CGRect cellFrame = CGRectMake(0,0,320,45);  
        UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:cellFrame reuseIdentifier:cellIdentifier] autorelease];

        CGRect bgFrame = CGRectMake(10,5,300,35);   
        UIImageView *backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"list_bg_up.png"]];
        backgroundView.frame = bgFrame;
        [cell addSubview:backgroundView];

        UILabel *txtLabel = [[UILabel alloc] initWithFrame:CGRectMake(20,10,250,25)];
        txtLabel.textColor=[UIColor whiteColor];
        txtLabel.backgroundColor = [UIColor clearColor];
        txtLabel.tag = 1;
        [cell addSubview:txtLabel];

        return cell;
    }   

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {        

        UITableViewCell *cell;

        static NSString *kDisplayCell_ID = @"DisplayCellID";

        //cell = [self.tableView dequeueReusableCellWithIdentifier:kDisplayCell_ID];
        cell = [tableView dequeueReusableCellWithIdentifier:kDisplayCell_ID];

        if(cell == nil) {
            cell = [self getCellContentView:kDisplayCell_ID];
        }

        aTopic = [topics objectAtIndex:indexPath.row];
        UILabel *txtLabel = (UILabel *)[cell viewWithTag:1];
        txtLabel.text = aTopic.description;

        return cell;
    }

    -(CGFloat)tableView:(UITableView *)tbView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
        return 45;
    }

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
        ResourcesViewController *resViewController = [[ResourcesViewController alloc] initWithNibName:@"ResourcesViewController" bundle:[NSBundle mainBundle]];
        resViewController.aTopic = [topics objectAtIndex:indexPath.row];
        [self.navigationController pushViewController:resViewController animated:YES];
        [resViewController release];
    }

if i want to change space between cells wat i hav to change in this code ....

now with this code i am able to display cells with some gap but i didnt understand how the gap defined...

A: 

If you're talking about vertical height of the cells, change this code:

-(CGFloat)tableView:(UITableView *)tbView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
        return 45;
    }

If you're talking about the horizontal space between data in the cell, you need to modify the CGRects here:

   CGRect cellFrame = CGRectMake(0,0,320,45);  
        UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:cellFrame reuseIdentifier:cellIdentifier] autorelease];

        CGRect bgFrame = CGRectMake(10,5,300,35);   
        UIImageView *backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"list_bg_up.png"]];
        backgroundView.frame = bgFrame;
        [cell addSubview:backgroundView];

        UILabel *txtLabel = [[UILabel alloc] initWithFrame:CGRectMake(20,10,250,25)];

Next time be a little more clear about what you're asking. And don't forget to accept answers to questions you ask. Cheers

Jordan