zoukankan      html  css  js  c++  java
  • MonoTouch.Dialog简介

    新建一个Single View Application项目

    添加程序集 MonoTouch.Dialog.dll引用

    删除 MainStoryboard.storyboard 

    添加空类Task.cs

    using System;
    
    namespace APITest
    {
    	public class Task
    	{
    		public Task ()
    		{
    		}
    		public string Name { get; set; }
    
    		public string Description { get; set; }
    
    		public DateTime DueDate { get; set; }
    	}
    }
    

      

    在AppDelegate.cs中重写方法FinishedLaunching,改为如下代码

    using System;
    using System.Linq;
    using System.Collections.Generic;
    
    using Foundation;
    using UIKit;
    using MonoTouch.Dialog;
    
    namespace APITest
    {
    	// 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;
    		RootElement _rootElement;
    		DialogViewController _rootVC;
    		UINavigationController _nav;
    		UIBarButtonItem _addButton;
    		int n=0;
    		public override UIWindow Window {
    			get;
    			set;
    		}
    		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    		{
    			_window = new UIWindow (UIScreen.MainScreen.Bounds);
    			_rootElement = new RootElement ("To Do List"){ new Section()};
    			_addButton = new UIBarButtonItem (UIBarButtonSystemItem.Add);
    			_addButton.Clicked+= (sender, e) => {
    				++n;
    				var task=new Task{ Name="task"+n , DueDate=DateTime.Now };
    				var taskElement=new RootElement(task.Name){
    					new Section(task.Name){new EntryElement(task.Name,"Enter Task Description",task.Description)},
    					new Section(task.Name){new DateTimeElement("DueDate", task.DueDate)}
    				};
    				_rootElement[0].Add(taskElement);
    			};
    			_rootVC = new DialogViewController (_rootElement);
    			_nav = new UINavigationController (_rootVC);
    			_rootVC.NavigationItem.RightBarButtonItem = _addButton;
    			_window.RootViewController = _nav;
    			_window.MakeKeyAndVisible ();
    			return true;
    		}
    		// This method is invoked when the application is about to move from active to inactive state.
    		// OpenGL applications should use this method to pause.
    		public override void OnResignActivation (UIApplication application)
    		{
    		}
    		
    		// This method should be used to release shared resources and it should store the application state.
    		// If your application supports background exection this method is called instead of WillTerminate
    		// when the user quits.
    		public override void DidEnterBackground (UIApplication application)
    		{
    		}
    		
    		// This method is called as part of the transiton from background to active state.
    		public override void WillEnterForeground (UIApplication application)
    		{
    		}
    		
    		// This method is called when the application is about to terminate. Save data, if needed.
    		public override void WillTerminate (UIApplication application)
    		{
    		}
    	}
    }
    

      双击Info.plist

    运行结果

  • 相关阅读:
    [svc]二三层数据格式&&三层数据如何匹配路由
    [na][dhcp]dhcp细枝末节&dhcp防攻
    [docker]使用quaaga实现(rip ospf)实现主机间容器互通
    [svc]centos7安装优化最佳姿势
    [svc]gns3模拟器及探讨几个bgp问题
    [svc]ip routing和no ip routing
    [docker]macvlan实现双vlan互通
    Jmeter 日志设置---如何设置java协议中被测jar的日志?
    Jmeter java协议配置文件导入
    eclipse, Log4j配置(真心的详细~)
  • 原文地址:https://www.cnblogs.com/bubugao/p/4486014.html
Copyright © 2011-2022 走看看