我有一个RadioGroup
非常多RadioElements
的子DialogViewController
:
Root.Add(
new Section() {
new RootElement ("Demo", new RadioGroup ("demogroup", 0)) {
new Section () {
from demoItem in bigItemList
select (Element) new RadioElement (demoItem)
}
}
}
);
我想启用搜索此嵌套 DVC 以使选择正确的RadioElement
更简单。因此,我实现了一个自定义RootElement
,它结合了传递一个组和创建一个 DVCEnableSearch
并使用它而不是上面的那个:
using System.Collections.Generic;
namespace MonoTouch.Dialog
{
public class SearchableRootElement : RootElement
{
public SearchableRootElement(string caption, Group group) : base(caption, group)
{
this.createOnSelected = x => {
return new DialogViewController(x) { EnableSearch = true };
};
}
}
}
不幸的是,在输入子 DVC 的搜索栏时,我遇到了以下崩溃:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at MonoTouch.Dialog.RadioElement.GetCell (MonoTouch.UIKit.UITableView tv) [0x00019] in /Developer/MonoTouch/Source/MonoTouch.Dialog/MonoTouch.Dialog/Elements.cs:1066
at MonoTouch.Dialog.DialogViewController+Source.GetCell (MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x00029] in /Developer/MonoTouch/Source/MonoTouch.Dialog/MonoTouch.Dialog/DialogViewController.cs:341
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at Demo.iOS.Application.Main (System.String[] args) [0x00001] in /Users/rodjatrappe/Projects/Claas/Dev/Apps/Demo.iOS/Main.cs:16
2013-06-22 14:15:02.296 DemoiOS[547:21b03] Unhandled managed exception: Object reference not set to an instance of an object (System.NullReferenceException)
at MonoTouch.Dialog.RadioElement.GetCell (MonoTouch.UIKit.UITableView tv) [0x00019] in /Developer/MonoTouch/Source/MonoTouch.Dialog/MonoTouch.Dialog/Elements.cs:1066
at MonoTouch.Dialog.DialogViewController+Source.GetCell (MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x00029] in /Developer/MonoTouch/Source/MonoTouch.Dialog/MonoTouch.Dialog/DialogViewController.cs:341
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at Demo.iOS.Application.Main (System.String[] args) [0x00001] in /Users/rodjatrappe/Projects/Claas/Dev/Apps/Demo.iOS/Main.cs:16
为什么会崩溃以及如何归档我上面描述的功能?