现在的位置: 首页 > 综合 > 正文

mono touch中viewcontroller载入过程常见的事件顺序

2014年06月24日 ⁄ 综合 ⁄ 共 1642字 ⁄ 字号 评论关闭

有不明白的地方欢迎入群 347636249 探讨

2014-01-23 13:41:01.898 GCForum[3165:c07] 构造函数

2014-01-23 13:41:01.899 GCForum[3165:c07] LoadView
2014-01-23 13:41:01.900 GCForum[3165:c07] ViewDidLoad
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
2014-01-23 13:41:01.911 GCForum[3165:7103] task 123
2014-01-23 13:41:01.912 GCForum[3165:7103] continuation task
2014-01-23 13:41:01.914 GCForum[3165:c07] ViewWillAppear
2014-01-23 13:41:01.916 GCForum[3165:c07] ViewWillLayoutSubviews
2014-01-23 13:41:01.916 GCForum[3165:c07] ViewDidLayoutSubviews
2014-01-23 13:41:02.270 GCForum[3165:c07] ViewDidAppear

============================>

public class CoursePlay : BaseViewController
	{
		public CoursePlay ()
		{
			Console.WriteLine ("构造函数");
		}

		public override void LoadView ()
		{
			base.LoadView ();
			Console.WriteLine ("LoadView");
		}

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			Console.WriteLine ("ViewDidLoad");

			Task[] tasks = new Task[1]; 

			tasks [0] = new Task (() => {
				Console.WriteLine ("task 123");
			});

			var continuation = Task.Factory.ContinueWhenAll (tasks, (param) => {
				Console.WriteLine ("continuation task");
				//Tools.Alert("continuation task");
			});

			tasks [0].Start ();
			continuation.Wait ();
		}

		public override void ViewWillAppear (bool animated)
		{
			base.ViewWillAppear (animated);

			this.View.AddSubview (ControlCenter.CreateDescript (new RectangleF (100, 100, 50, 10), "4564645", "0,0,0", 12));

			Console.WriteLine ("ViewWillAppear");
		}

		public override void ViewWillLayoutSubviews ()
		{
			base.ViewWillLayoutSubviews ();
			Console.WriteLine ("ViewWillLayoutSubviews");
		}

		public override void ViewDidLayoutSubviews ()
		{
			base.ViewDidLayoutSubviews ();
			Console.WriteLine ("ViewDidLayoutSubviews");
		}

		public override void ViewDidAppear (bool animated)
		{
			base.ViewDidAppear (animated);
			Console.WriteLine ("ViewDidAppear");
		}

		//...

	}

抱歉!评论已关闭.