• 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

    运行结果

  • 相关阅读:
    spring mybatis 关于 basepackage 和 mapperLocations 的通配符匹配实例
    nginx 隐藏版本信息
    nginx 虚拟主机配置
    分析解决 spring quartz 中出现的执行两次问题
    nginx 安装配置和常用命令
    JMX 远程监控 Linux tomcat 功能实现
    jvm 类加载机制
    jvm 类文件结构学习
    转 MySQL: Starting MySQL….. ERROR! The server quit without updating PID file解决办法
    MySQL提示:The server quit without updating PID file问题的解决办法
  • 原文地址:https://www.cnblogs.com/bubugao/p/4486014.html
Copyright © 2020-2023  润新知