cellForRowAtIndexPath not called but numberOfRowsInSection called
ios, objective-c, uitableview
Solution
You need to set the Frame of `UITableView`
Problem
I have a simple problem but I can't understand what is. I have a `UIViewControler` (called `RootController`) that load a `UIView` (called `SecondView`) that contain a `tableView`. The problem is that the `UIView` call the `numberOfSectionsInTableView` and the `numberOfRowsInSection` but don't call `cellForRowAtIndexPath` and the table view is not displayed. The code of the `RootViewController` is: ``` SecondView *secondView = [[seconddView alloc] initWithFrame:CGRectMake(0, 60, self.view.bounds.size.width, self.view.bounds.size.height)]; [self.view addSubview:secondView]; ``` And the code of the `SecondView` is: ``` @interface SecondView () <UITableViewDelegate, UITableViewDataSource> @property (nonatomic,retain) UITableView *table; @end @implementation SecondView @synthesize table; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.table = [[UITableView alloc] init]; self.table.delegate = self; self.table.dataSource = self; [self addSubview:self.table]; } return self; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.textLabel.text = @"Prova"; return cell; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 5; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } ``` Can you help me to find the problem? Thank you.