ここで何か不足している可能性がありますが、手動で行の選択を解除すると、カスタム クラスDeselect
でイベントをトリガーできません。Element
カスタム描画を行うためにセルをオーバーライドしていますが、セルが選択/選択解除されたときにフォントの色を変更したいと考えています。
実際の問題の実際の例を以下に詳しく説明します。
public class TestViewController : DialogViewController
{
public TestViewController () : base(UITableViewStyle.Plain, null, true)
{
Root = new RootElement(null);
var section = new Section();
for (int i = 0; i <= 10; i++)
{
var element = new MyCustomElement();
element.Tapped += (dvc, tableView, indexPath) => {
var sheet = new UIActionSheet("", null, "Cancel", null, null);
sheet.Dismissed += delegate(object sender, UIButtonEventArgs e) {
tableView.DeselectRow(indexPath, false);
};
sheet.ShowInView(View);
};
section.Add (element);
}
Root.Add (section);
}
}
public class MyCustomElement : Element, IElementSizing {
static NSString mKey = new NSString ("MyCustomElement");
public MyCustomElement () : base ("")
{
}
public MyCustomElement (Action<DialogViewController,UITableView,NSIndexPath> tapped) : base ("")
{
Tapped += tapped;
}
public override UITableViewCell GetCell (UITableView tv)
{
var cell = tv.DequeueReusableCell (mKey);
if (cell == null)
cell = new UITableViewCell (UITableViewCellStyle.Default, mKey);
return cell;
}
public float GetHeight (UITableView tableView, NSIndexPath indexPath)
{
return 65;
}
public event Action<DialogViewController, UITableView, NSIndexPath> Tapped;
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
Console.WriteLine("Selected!");
if (Tapped != null)
Tapped (dvc, tableView, path);
}
public override void Deselected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
// does not trigger when deselect manually invoked
Console.WriteLine("Deselected!");
base.Deselected (dvc, tableView, path);
}
}
Deselected
また、それ自体でイベントをオーバーライドしDialogViewController
、カスタムを作成してそこでイベントをオーバーライドしようとしましたが、まだトリガーされていません。トリガーする唯一の方法は、ハンドラーを削除して別のセルを選択することです。Source
RowDeselected
Tapped
この問題を回避するために、私が現在行っていることは、 を呼び出した後に要素を手動で強制的に更新することですが、トリガーされない理由DeselectRow
を知りたいです。