我有一个RadioGroup
有非常多RadioElements
为一分DialogViewController
:如何在MonoTouch.Dialog中启用搜索RadioGroup DVC?
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
它结合了经过一个组,创建具有EnableSearch
一个DVC,并用它来代替上述的一个:
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
为什么它崩溃以及如何归档上述功能?
感谢。进入相同的问题,党用你的建议解决它。但是,这是如何解决即使在应用了过滤器之后也将第n个元素标记为选中状态的可用性问题?此问题是否仍然存在于您建议的解决方案中,还是我缺少部分观点?谢谢! – Corstiaan