iOS: The contents of the first UITableView cell with a different type are not di...
source link: https://www.codesd.com/item/ios-the-contents-of-the-first-uitableview-cell-with-a-different-type-are-not-displayed.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
iOS: The contents of the first UITableView cell with a different type are not displayed
I have an UITableView
in my UIViewController
. The first cell has type1
and the others type2
. My problem is that the content of my first cell is never displayed. This is my code:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == 0) {
return 240;
}
return 90;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row == 0) {
Type1Cell * tmpCell1 = [tableView dequeueReusableCellWithIdentifier:@"type1Cell"];
if (tmpCell1 == nil) {
tmpCell1 = [[Type1Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"type1Cell"];
}
//set data
return tmpCell1;
} else {
Type2Cell * tmpCell = [tableView dequeueReusableCellWithIdentifier:@"type2Cell"];
if (tmpCell == nil) {
tmpCell = [[Type2Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"type2Cell"];
}
//set data
return tmpCell;
}
}
The first cell has the same specified height, but it's always blank. I don't have this problem with the other cells.
Make sure Cell content View or any-other mistakenly checked Hidden
property to TRUE.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK