如果我有以下代码:
MyClass pClass = new MyClass();
pClass.MyEvent += MyFunction;
pClass = null;
Run Code Online (Sandbox Code Playgroud)
pClass会被垃圾收集吗?或者它会在它们发生的时候仍然停止发射?我是否需要执行以下操作才能进行垃圾回收?
MyClass pClass = new MyClass();
pClass.MyEvent += MyFunction;
pClass.MyEvent -= MyFunction;
pClass = null;
Run Code Online (Sandbox Code Playgroud) 我的应用程序在MT 3.0中运行良好.现在我升级了.当按钮在ContentView中时,我看到错误.单击按钮时发生崩溃.码:
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPa
float width = tableView.Bounds.Width - 70;
var cell = tableView.DequeueReusableCell(kCellIdentifier);
//if (cell == null)
//{
cell = new UITableViewCell(UITableViewCellStyle.Subtitle, kCellIdentifier);
// }
var behavior = tvc.behaviors.ElementAt(indexPath.Row);
cell.TextLabel.Text = behavior.Name;
cell.TextLabel.Font = UIFont.BoldSystemFontOfSize(22f);
cell.DetailTextLabel.Text = behavior.Definition;
var view = UIButton.FromType(UIButtonType.Custom);
view.Tag = indexPath.Row;
view.SetImage(UIImage.FromBundle("Images/plus.png"), UIControlState.Normal);
view.Frame = new RectangleF(width - 50, 10, 50, 50);
view.TouchUpInside += IncrementBehavior;
var label = new UILabel(new RectangleF(width - 80, 10, 50, 50));
label.Text = behavior.CurrentCount.ToString();
label.BackgroundColor …Run Code Online (Sandbox Code Playgroud)