摘要概述
我的UITableViewSource中有以下覆盖GetCell。 一切正常,但我想让单元格左侧的图像更小,而不必调整大小。 基本上我只是想减少框架,(30宽x 30高)....也许可以绕过角落(类似于Whatsapp的开放式聊天列表)。
问题
简单地将新的RectangleF应用于ImageView的Frame属性似乎不起作用。
if (tableItems[indexPath.Section].Items[indexPath.Row].ImageName != null)
{
//RESIZE IMAGE VIEW
cell.ImageView.Frame = new RectangleF(5,5,30,30);
Console.WriteLine("Image name: " + tableItems[indexPath.Section].Items[indexPath.Row].ImageName);
cell.ImageView.Image = UIImage.FromFile (tableItems[indexPath.Section].Items[indexPath.Row].Image);
}
CODE
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell (cellIdentifier);
Custom_UITableItem item = tableItems[indexPath.Section].Items[indexPath.Row];
var cellStyle = UITableViewCellStyle.Subtitle;
// if there are no cells to reuse, create a new one
if (cell == null)
{
cell = new UITableViewCell (cellStyle, cellIdentifier);
}
try
{
if(cellAccessoryButtons.Count > 0)
{
var cellAccessoryButton = cellAccessoryButtons [indexPath.Row];
cell.AccessoryView = cellAccessoryButton;
}
cell.TextLabel.Text = tableItems[indexPath.Section].Items[indexPath.Row].Heading;
cell.TextLabel.Font = AppSettings.CellDetailTextLabelFontSize;
cell.TextLabel.LineBreakMode = UILineBreakMode.WordWrap;
cell.TextLabel.Lines = 2;
cell.DetailTextLabel.Text = tableItems[indexPath.Section].Items[indexPath.Row].SubHeading;
cell.DetailTextLabel.Font = AppSettings.CellDetailTextLabelFontSize;
cell.DetailTextLabel.LineBreakMode = UILineBreakMode.WordWrap;
cell.DetailTextLabel.Lines = 2;
if (tableItems[indexPath.Section].Items[indexPath.Row].ImageName != null)
{
//RESIZE IMAGE VIEW
cell.ImageView.Frame = new RectangleF(5,5,30,30);
Console.WriteLine("Image name: " + tableItems[indexPath.Section].Items[indexPath.Row].ImageName);
cell.ImageView.Image = UIImage.FromFile (tableItems[indexPath.Section].Items[indexPath.Row].Image);
}
var trackUploadedDateFrame = new RectangleF (87, 55, 100, 20);
var trackUploadedDate = new UILabel (trackUploadedDateFrame);
trackUploadedDate.BackgroundColor = UIColor.Clear;
trackUploadedDate.Font = AppSettings.TrackUploadedDateFontSize;
trackUploadedDate.TextAlignment = UITextAlignment.Left;
trackUploadedDate.Text = "Uploaded: 16/10/13";
cell.AddSubview (trackUploadedDate);
}
catch(Exception ex)
{
Console.WriteLine (ex.ToString ());
}
return cell;
}
答案 0 :(得分:1)
简而言之,“去过那里,完成了”让我告诉你自定义股票UITableViewCell - 特别是它的ImageView是一个皇家的痛苦。
根据我的经验,通过子类化UITableViewCell更容易实现您的设计目标 - 使用IB代码或.xib - 除非股票UITableViewCell的功能非常接近您自己的目标。
答案 1 :(得分:0)
使用以下功能调整图像大小,然后将其设置为表格单元格图像视图
function bv_replace_tunbridge($content) {
$content = str_replace('tunbridge', 'tûnbridge', $content);
return $content;
}
add_filter('the_content','bv_replace_tunbridge');