проблема с таблицей в iphone - PullRequest
       3

проблема с таблицей в iphone

1 голос
/ 19 сентября 2011

У меня есть UITableView, который установил свойство Grouped. И это выглядит так с закругленными краями.И это здорово.

enter image description here

Как только я начинаю прокручивать UITabelView, круглые края исчезают, и это выглядит так:

enter image description here

Круглые края исчезают!

Как мне поступить так, и когда я прокручиваю UITableView вверх и вниз, круглые края сохраняются, как на первом рисунке?

Соответствующий кодкак спросили:

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

}

Ответы [ 3 ]

3 голосов
/ 19 сентября 2011

Это потому, что на первом изображении вы видите верхнюю строку в сгруппированном табличном представлении, которая округлена, но только верхняя и нижняя строки округляются таким образом, поэтому при прокрутке вы видите средние строки, что является нормальным.

1 голос
/ 19 сентября 2011

Так работают сгруппированные таблицы.Углы каждой группы округлены, а не углы самого табличного представления.Взгляните на приложение «Настройки», и вы увидите, что углы каждой группы закруглены;По сути, в настройках вы увидите то же самое, что и в своем приложении, за исключением того, что границы представления таблицы в настройках соответствуют границам представления прокрутки.Короче говоря, ваше представление таблицы работает так, как задумано.

Если вы хотите, чтобы углы видимой части таблицы всегда округлялись, вы можете заглянуть в углы представления таблицы.Один из способов сделать это - установить свойство cornerRadius нижележащего слоя:

myTableView.layer.cornerRadius = 10.0;

Если вы попробуете этот подход, вам, вероятно, также понадобится указать ширину и цвет границы слоя.

0 голосов
/ 19 сентября 2011
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...