私のUITableViewには、commonCellとexpandedCellの2種類のセルがあります。拡張されたセルはタップで展開され、完全な説明が表示され、ラベルはそれに応じて調整されます。つまり、ラベルの高さは動的です。 UITableView snapshot showing cell with attachment openedフレームを変更してもUIViewの高さが減少しない
以下のコードはすべて、内部書かれている - のtableView:heightForRowAtIndexPathを:拡大セル用:あなたは私のコードで見ることができるように UITableView snapshot showing cell without attachment opened
:
// Debug area log before changing frame
//Printing description of viewAttachment:
//UIView: 0x7f8f84d8b050; frame = (16 107; 288 20); autoresize = RM+BM; tag = 314; layer = CALayer: 0x7f8f84d7a340
CGFloat height =[[HSHelper sharedInstance] getLabelSizeFortext:help.helpDescription forWidth:labelDescText.frame.size.width WithFont:kFontRobotoRegular(15).height;
height = (height<20.0)? 20.0 + 20: height + 10;
CGFloat heightAttachment = 0.0;
if (help.helpAttachmentName.length != 0) {
heightAttachment = [HSHelper sharedInstance].isiPad ? 35.0 :20.0;
} else {
CGRect framee = viewAttachment.frame;
framee.size.height = 0.0f;
viewAttachment.frame = framee;
}
// Debug area log after changing frame
//Printing description of viewAttachment:
//UIView: 0x7f8f84d8b050; frame = (16 107; 288 0); autoresize = RM+BM; tag = 314; layer = CALayer: 0x7f8f84d7a340
return height + 23.0 + heightAttachment + 34.0;
画像は、問題を表示しますコメント部分には、デバッグ領域に出力された結果が表示され、viewAttachmentの高さが変更されたことが明確に表示されます。しかし、シミュレータのスナップショットイメージには、ファイルが添付されていない空白領域が表示されます。
また、私は、ストーリーボードでviewAttachmentの高さを '='ではなく '< ='に設定しました。
この奇妙な問題で私を助けてください。前もって感謝します。
を設定しようか? – Nitin
もちろん@ニチン。私はすでにそれを試みました。 –
ログは(16 107; 288 0)としてフレームを示します。高さが0であることを意味します。 –