码迷,mamicode.com
首页 > 其他好文 > 详细

MonoTouch.Dialog简介

时间:2015-05-07 21:48:25      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:

新建一个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

技术分享技术分享

运行结果

技术分享技术分享技术分享

 

MonoTouch.Dialog简介

标签:

原文地址:http://www.cnblogs.com/bubugao/p/4486014.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!