adrian
adrian

Reputation: 4594

issue with tableview in iphone

I have a UITableView which has set the property Grouped.And it looks like this with rounded edges. And it's great.

enter image description here

As soon I start scrolling the UITabelView the round edges dissappear and it looks like this:

enter image description here

The round edges disappear!

How should I proceed that and when I scroll the UITableView up and down the round edges are kept as in the first picture?

The relevant code as asked:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
     return 1;
}

// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
     return [nameCatalog count];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];

        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.backgroundColor = [UIColor clearColor];
        cell.selectionStyle = UITableViewCellSelectionStyleGray;
        cell.backgroundView.opaque = NO;

        cell.textLabel.backgroundColor = [UIColor clearColor];
        cell.textLabel.opaque = NO;
        cell.textLabel.textColor = [UIColor whiteColor];
        cell.textLabel.highlightedTextColor = [UIColor whiteColor];
        cell.textLabel.font = [UIFont boldSystemFontOfSize:18];

        cell.detailTextLabel.backgroundColor = [UIColor clearColor];
        cell.detailTextLabel.opaque = NO;
        cell.detailTextLabel.textColor = [UIColor whiteColor];
        cell.detailTextLabel.highlightedTextColor = [UIColor whiteColor];
        cell.detailTextLabel.font = [UIFont systemFontOfSize:14];
    }

    [[cell textLabel] setText:[[nameCatalog objectAtIndex:indexPath.row] valueForKey:@"name"]];
    return cell;
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NSString *escapedString = [[[nameCatalog objectAtIndex:indexPath.row] valueForKey:@"url"]      stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url=[NSURL URLWithString:escapedString];

    [webView loadRequest:[NSURLRequest requestWithURL:url]];


    [self.view addSubview:webView];
    [self.navigationController pushViewController:webView animated:YES];
    [webView setHidden:NO];
    UIBarButtonItem *infoButton = [[UIBarButtonItem alloc] 
                                   initWithTitle:@"Retour" style:UIBarButtonItemStyleBordered target:self action:@selector(tableRetour:)];

    self.navigationItem.leftBarButtonItem = infoButton;
    [self.view addSubview:webView];

}

Upvotes: 1

Views: 820

Answers (3)

Caleb
Caleb

Reputation: 124997

That's just how grouped tables work. It's the corners of each group that are rounded, not the corners of the table view itself. Take a look at the Settings app and you'll see that the corners of each group are rounded; you'll see essentially the same thing in Settings that you see in your app, except that the bounds of the table view in Settings correspond to the bounds of the scroll view. In short, your table view is working as designed.

If you want the corners of the visible part of the table to be rounded at all times, you could look into rounding the table view's corners. One way to do that is to set the cornerRadius property of the underlying layer:

myTableView.layer.cornerRadius = 10.0;

If you try that approach, you'll probably also want to specify the layer's border width and color.

Upvotes: 1

Norman G
Norman G

Reputation: 769

That's because in the first picture you are seeing the top row in the grouped tableView which is rounded, but only the top and bottom rows are rounded like that, so when you scroll you are seeing the middle rows which is normal.

Upvotes: 3

Related Questions