Tuesday, August 7, 2012

MonoTouch Bare Bones


using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace myNameSpace
{
   public class Application
   {
      static void Main(string[] args)
      {
         UIApplication.Main(args, null, "AppController");
      }
   }


   [Register ("AppController")]
   public class AppController : UIApplicationDelegate 
   {
      UIWindow window;

      public override bool FinishedLaunching(UIApplication app, NSDictionary options)
      {
         // create the main view controller
         var vc = new MainViewController();

         // create main window and add main view controller as subclass
         window = new UIWindow(UIScreen.MainScreen.Bounds);
         window.AddSubview(vc.View);
         window.MakeKeyAndVisible();

         return( true );
      }

      public override void OnActivated(UIApplication application) 
      {
         //required override on iOS 3.0
      }
   }


   [Register]
   public class MainViewController : UIViewController 
   {
      public override void ViewDidLoad()
      {
         base.ViewDidLoad();

         //custom code can start here...
         Console.WriteLine("App Loaded");
      }
   }


}//myNameSpace

No comments:

Post a Comment