나는 표 셀의 높이를 콘텐츠 높이에 맞게 만드는 방법을 알아 내기 위해 인터넷 서핑을 해왔다.Monotouch : UITableViewCell height
나는이 샘플을 보려고 노력했다 .... http://simon.nureality.ca/simon-says-project-d-uitableviewcells-autosize-based-on-text-height-in-monotouch-heres-how/ ...하지만 나는 그것을 작동시킬 수 없다.
은 여기까지 .. 셀 높이가 실제로 작동하고 내 코드지만, 텍스트 (대신 전체 프레임을 dilling의) dotts를 trailling와 중심 :public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
string item = this.Lst.Items [indexPath.Section];
UITableViewCell cell = tableView.DequeueReusableCell (_cellIdentifier);
if (cell == null) {
cell = new UITableViewCell (UITableViewCellStyle.Default, _cellIdentifier);
cell = new UITableViewCell (UITableViewCellStyle.Subtitle, _cellIdentifier);
}
// Find the height...
SizeF textWidth = new SizeF (tableView.Bounds.Width - 40, float.MaxValue);
SizeF textSize = tableView.StringSize(item, Font, textWidth, LineBreakMode);
// Textlabel...
cell.TextLabel.Text = item;
cell.TextLabel.Font = Font;
cell.TextLabel.Frame = new RectangleF(cell.TextLabel.Frame.X, cell.TextLabel.Frame.Y, textSize.Width, textSize.Height);
//cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
cell.ImageView.Image = PlaceholderImage;
cell.EditingAccessory = UITableViewCellAccessory.DisclosureIndicator;
// Sizing the cell...
RectangleF rectCell = cell.Frame;
rectCell.Height = textSize.Height;
cell.Frame = rectCell;
return cell;
}
public override float GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
string item = this.Lst.Items [indexPath.Section];
SizeF size = new SizeF (tableView.Bounds.Width - 40, float.MaxValue);
float height = tableView.StringSize (item, Font, size, LineBreakMode).Height + 10;
return height;
}
을 그리고는 다음과 같습니다 .. .
잘못 어떤 생각?
감사합니다.
모조
셀의 ContentView의 일부로 UILabel을 추가 할 수 있습니까? TextLabel 프레임을 조작하는 것보다 훨씬 쉬울 것 같습니다. – Anuj
Emmm dunno (이게 나에게 새로운 것) : – MojoDK