カスタムセルで UITableView を使用しています。各セルには、DisclosureIndicator に設定されたアクセサリがあります。ポートレートモードの時は大丈夫です。回転して横向きモードにすると、アクセサリは縦向きと横向きの 2 回表示されます。セルのサブビューも確認しました。横向きのときは、アクセサリの UIButton が 2 回表示されます。
他の誰かがこの問題に遭遇しましたか? それを修正するアイデアはありますか?
要約すると、これが私たちが持っているものです:
データ ソースを持ち、いくつかのカスタム セルを使用する UITableView。これらのセルはあまり機能しません。ドキュメント名を表示する UILabel のみが含まれています。
ポートレートモードでは、次のものがあります。
資料1 > 資料2 > 資料3 >
風景モードでは、次のようになります。
資料1 >> 資料2 >> 資料3 >>
テーブル ソース (これは C# であることに注意してください):
public class DocumentTableSource : MvxSimpleTableViewSource
{
public DocumentTableSource(UITableView tableView) : base(tableView, typeof(DocumentTableCell), null)
{
}
public override float GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
return DocumentTableCell.GetCellHeight();
}
}
カスタム セル (これは C# であることに注意してください):
[Register("DocumentTableCell")]
public class DocumentTableCell : MvxTableViewCell
{
public const int CELL_HEIGHT = 44;
public static NSString Key = new NSString("DocumentTableCell");
private bool initialized;
private UILabel lblDoc;
public DocumentTableCell(IntPtr handle) : base(handle)
{
Accessory = UITableViewCellAccessory.DisclosureIndicator;
lblDoc = new UILabel() {TextColor = AppearanceSettings.ColorDefault};
this.DelayBind(() =>
{
var set = this.CreateBindingSet<DocumentTableCell, Document>();
set.Bind(lblDoc).To(p => p.Name);
set.Apply();
});
}
public static float GetCellHeight()
{
return CELL_HEIGHT;
}
public override void UpdateConstraints()
{
base.UpdateConstraints();
if (!initialized)
{
ContentView.AddSubview(lblDoc);
ContentView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
ContentView.AddConstraints(
lblDoc.AtBottomOf(ContentView, 6),
lblDoc.AtLeftOf(ContentView, AppearanceSettings.HORIZONTAL_MARGIN)
);
initialized = true;
}
}
}