简体   繁体   中英

UITableView: cellForRowAtIndexPath not being called

I have a problem and cellForRowAtIndexPath is not being called. I checked that both the no of row and sections are not zero. Thanks in advance for any advise.

- (void)viewDidLoad
{
    [super viewDidLoad];

    MakeupTable=[[UITableView alloc]init];
    MakeupTable.dataSource=self;
    MakeupTable.delegate=self;

    [MakeupTable reloadData];


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==0) {
        return 4;
    }else{
        return 1;
    }

}


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

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    return cell;
}

确保将此类设置为“表”视图委托:

 @interface YourViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM