我使用Monotouch.Dialog(Xamarin.iOS版本:6.2.0.65)来创建一个放射性元素RadioGroup中。我只想在第二个屏幕(用户从长列表中选择)中搜索功能,所以我创建了一个单独的DialogViewController,其中我启用了搜索过滤器(enableSearch = true)。Monotouch.Dialog:碰撞与EnableSearch和定制rootElement的
当在搜索框中输入,在放射性元素的GetCell方法应用程序崩溃。
“对象引用不设置为一个对象的一个实例,”上Element.cs的1064线。我有GC问题吗?我设法模拟它在一个小应用程序...不注重一些奇怪的字段成员,这就是我测试如果我开始GC ...
using MonoTouch.Dialog;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace SearchCrash
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
// class-level declarations
UIWindow window;
public UINavigationController NavigationController { get; set; }
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
window = new UIWindow(UIScreen.MainScreen.Bounds);
this.NavigationController = new UINavigationController();
this.NavigationController.PushViewController(new FirstViewController(this.NavigationController), true);
window.RootViewController = this.NavigationController;
window.MakeKeyAndVisible();
return true;
}
}
public class FirstViewController : DialogViewController
{
private UINavigationController controller;
private LocatiesRootElement locRootElement;
private RadioGroup radioGroup;
public FirstViewController(UINavigationController c) : base(new RootElement("Test"), true)
{
this.controller = c;
}
public override void ViewDidLoad()
{
Section section = new Section();
radioGroup = new RadioGroup(0);
locRootElement = new LocatiesRootElement("test", radioGroup, this.controller);
section.Add(locRootElement);
Root.Add(section);
}
}
public class LocatiesRootElement : RootElement
{
private UINavigationController navigationController;
private LocatiesViewController locatiesViewController;
public LocatiesRootElement(string selectedLocatie, RadioGroup group, UINavigationController controller) : base("Locatie", group)
{
this.navigationController = controller;
this.locatiesViewController = new LocatiesViewController(this);
}
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
this.navigationController.PushViewController(this.locatiesViewController, true);
}
}
public class LocatiesViewController : DialogViewController
{
public LocatiesViewController(LocatiesRootElement root) : base(root, true)
{
this.EnableSearch = true;
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
Section sectionList = new Section();
RadioElement radioElement1 = new RadioElement("item 1");
RadioElement radioElement2 = new RadioElement("item 2");
sectionList.Add(radioElement1);
sectionList.Add(radioElement2);
Root.Add(sectionList);
}
}
}
我不知道这是它。但是,你是自定义的根元素看起来不正确。您是否有使用自定义根元素的原因?即使这是正确的,我也没有看到为Root.add(sectionList)实际创建'RootElement'的位置;'另外,如果您没有启用搜索,这是否工作? – BRogers 2013-03-08 17:52:45
这是一个死的问题吗? – BRogers 2013-03-11 01:13:03
没有死的问题,我只是没有在周末工作......它没有过滤器时工作正常。获取单元崩溃时使用过滤器。 RootElement是通过LocatiesViewController的构造函数创建的。 – Peesjee 2013-03-11 07:35:12