Noob Xamarin/MonoTouch.Dialog问题:我在Xamarin Studio的故事板设计器中布置了我的iOS应用程序。我有一个UINavigationController的根视图,包含一个带有静态单元的UITableView,实质上是创建一个主菜单。单元格延续到它们各自的UIViewControllers。将一个DialogViewController拖到一个ViewController到NavigationController栈上给出2页
我想使用MonoTouch.Dialog布局about /设置屏幕。然而,由于我在Xamarin/MonoTouch.Dialog中的新手性,我遇到了一些将整体故事板方法与部分MonoTouch.Dialogue方法相结合的问题。当我在UIViewController上实例化一个新的DialogViewController时,最初的UITableView(AccountViewController),我基本上获得了两个视图添加到导航堆栈,第一个只出现简要,然后显示DialogViewController。我的代码实例化DialogViewController是这样的:
partial class AccountViewController : UIViewController
{
public AccountViewController (IntPtr handle) : base (handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
var root = new RootElement ("Settings") {
new Section(){
new BooleanElement ("Airplane Mode", false),
new RootElement ("Notifications", 0, 0) {
new Section (null,
"Turn off Notifications to disable Sounds\n" +
"Alerts and Home Screen Badges for the\napplications below."){
new BooleanElement ("Notifications", false)
}
}}
};
var dialog = new DialogViewController (root, true);
this.NavigationController.PushViewController (dialog, true);
//this.NavigationController.PresentViewController (dialog, true, null); tried this but then the UINavigationController shows no back buttons
//View.AddSubview (dialog.View); tried this but then the UINavigationController shows no back buttons
}
}
我可能推DialogViewController下旬在堆栈中,创造了中介黑屏,但我无法揣摩出正确的地方是推动DialogViewController根据我当前的体系结构导入导航堆栈。 在interwebs中的大多数样本几乎100%MonoTouch.Dialog,没有故事板...
谢谢!
好的,谢谢。所以我想问题是:当UITableViewController中的某个静态单元被点击/触摸时,如何实例化DialogViewController,然后将该DialogViewController推到导航栈上? – Corstiaan 2015-02-25 09:30:47
@Corstiaan在你的UITableSource(或你的UITableViewController)中,你想覆盖'RowSelected()'方法。这是当从UITableView的一行被点击或选中时触发的方法。查看'indexPath.Row'和/或'indexPath.Section'来确定哪一行被选中。从那里您可以将DialogViewController推入导航堆栈。看看如何使用UITableViews的Xamarin文档,它会给你更详细的代码示例。 [Xamarin Docs for UITableViews](http://developer.xamarin.com/guides/ios/user_interface/tables/) – SharpMobileCode 2015-02-25 16:18:12
受你答案的启发,我解决了它。将在明天发布代码:-) – Corstiaan 2015-02-25 17:20:42