相关疑难解决方法(0)

事件处理程序是否阻止垃圾收集发生?

如果我有以下代码:

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)

.net c# garbage-collection event-handling

178
推荐指数
3
解决办法
3万
查看次数

ContentView中的按钮会导致MonoTouch运行时崩溃.Monotouch 4.0中的错误?

我的应用程序在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)

c# xamarin.ios ipad ios

3
推荐指数
1
解决办法
2439
查看次数

标签 统计

c# ×2

.net ×1

event-handling ×1

garbage-collection ×1

ios ×1

ipad ×1

xamarin.ios ×1