0

hello I'm trying to change the width of the cells in a tableview programaticallly I have this code initially

`

-(void)viewDidLoad
{
[super viewDidLoad];
    [self.theTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    CGRect frame = CGRectMake(100, 0, 200.0, 768.0);                         
    self.theTableView = [[UITableView alloc] initWithFrame:frame];
    theTableView.delegate = self;
    theTableView.dataSource = self;
    [self.view addSubview:theTableView];
    self.title = @"TableView";

} ` works one way but the problem is that the cells are duplicated as shown below

image

thank you very much for your help

0

1 Answer 1

0

Cell's placed inside a tableview should autosize to the width of the tableview. In your code you are setting the width of the tableview to 200. Therefore the cells should be 200 as well. Are you using a custom cell or just the default UITableViewCell? If you are using a custom cell and setting the cell's width to something different than the tableview width it may be causing the duplication.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.