【发布时间】:2019-04-01 22:46:39
【问题描述】:
我发现了一件很奇怪的事情。
1.我在我的 ViewController 中保留一个视图。
- 在 TableView 中添加此视图。
`
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 100;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
cell.textLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row];
if(indexPath.row == 0)
{
[cell.contentView addSubview:self.imageContainer];
}else
{
if(self.imageContainer.superview == cell.contentView)
{
[self.imageContainer removeFromSuperview];
}
}
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == 0)
{
return 200;
}
else
{
return 44;
}
}
【问题讨论】:
-
请将代码发布为文本,而不是图像