我設置的heightForRowAtIndexPath這樣的設置高度:IOS heightForRowAtIndexPath,空單元
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
/* Contains the string */
NSString *allStrings = [self convertMainData:indexPath];
UIFont *cellFont = [UIFont fontWithName:@"Helvetica" size:17.0];
CGSize constraintSize = CGSizeMake(280.0f, MAXFLOAT);
CGSize labelSize = [allStrings sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:NSLineBreakByWordWrapping];
return labelSize.height + 20;
}
調用此方法時,表不爲空,且尺寸被正確地計算,現在的問題是,如果有在表中的數據,所有的細胞得到他們的高度變化:
http://img716.imageshack.us/img716/3025/yrgt.png
我已經試過檢查此在委託方法
if([tableview cellForRowAtIndexPath:IndexPath] == nil)
return 20;
但是這會返回一個錯誤,我也嘗試了將它包裝在!= nil中,但是這沒有效果,那麼我如何將空行留在默認高度?
您的圖片鏈接無效,我完全不理解您的問題陳述。你能澄清一點嗎? –
你是什麼意思的空行? – rdelmar
http://img716.imageshack.us/img716/3025/yrgt.png –