Objective c UITableView:未调用cellForRowAtIndexPath
我遇到问题,未调用CellForRowatineXpath。我检查了行数和节数是否都不是零。提前谢谢你的建议Objective c UITableView:未调用cellForRowAtIndexPath,objective-c,uitableview,Objective C,Uitableview,我遇到问题,未调用CellForRowatineXpath。我检查了行数和节数是否都不是零。提前谢谢你的建议 - (void)viewDidLoad { [super viewDidLoad]; MakeupTable=[[UITableView alloc]init]; MakeupTable.dataSource=self; MakeupTable.delegate=self; [MakeupTable reloadData]; - (NSIn
- (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>
numberOFRows和NumberOfSection是否被调用?您是否已将代理确认添加到标题中?