开发者

How can I remove/adjust the cell padding/margin of UITableViewCell?

开发者 https://www.devze.com 2023-03-22 16:49 出处:网络
I am using the b开发者_如何学Celow code; it works but the text appears with few pixels left padding/margin.

I am using the b开发者_如何学Celow code; it works but the text appears with few pixels left padding/margin.

How can I remove/adjust the cell padding/margin?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [resultaterTableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell.textLabel.text = [resultater objectAtIndex:indexPath.row];
}


Use the custom cell:

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

    static NSString *CellIdentifier = @"Custom";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {

        UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:cellFrame reuseIdentifier:CellIdentifier] autorelease];

    }

            CGRect *customframe = CGRectMake(2, 2, 250, 30); **// Set the frame** as per your own.
            UILabel *lbl = [[UILabel alloc] initWithFrame:customframe];
            lbl.text = [resultater objectAtIndex:indexPath.row]; **// Set the label value from array**
            [cell.contentView addSubview:lbl];
            [lbl release];
return cell;

}
0

精彩评论

暂无评论...
验证码 换一张
取 消