• mono touch登录设计


    需要对MonoTouch.Dialog-1进行引用;


    using System;
    using System.Collections.Generic;
    using System.Linq;
    
    using MonoTouch.Foundation;
    using MonoTouch.UIKit;
    using MonoTouch.Dialog;
    using System.Diagnostics;
    
    namespace MTDLoginDemo
    {
        [Register ("AppDelegate")]
        public partial class AppDelegate : UIApplicationDelegate
        {
            // class-level declarations
            UIWindow window;
            EntryElement login, password;
    
            public override bool FinishedLaunching (UIApplication app, NSDictionary options)
            {
                window = new UIWindow (UIScreen.MainScreen.Bounds);
                       
    			window.RootViewController = new DialogViewController (new RootElement ("Login") {
    				new Section ("用户登录"){
    					(login = new EntryElement ("用户名", "输入用户名", "")),
    					(password = new EntryElement ("密码", "用户密码", "", true))
                    },
                    new Section ("caption1231","footer123131221321") {
    					new StringElement ("登录", delegate{ 
    						Alert(login.Value+" " +password.Value);
    					})   
                    }
                });
    
                window.MakeKeyAndVisible ();
                
                return true;
            }
    
    		private void Alert(string msg)
    		{
    			UIAlertView av = new UIAlertView ("提示", msg, null, "确定", null);
    			av.Show ();
    		}
        }
    }
    

    效果图: 这里需要指出的是 Section有5个重载,可以自行试验一下,uiview相当于在上面或下面添加uiview对象的具体实例


    ================分割线==================

    using System;
    using System.Collections.Generic;
    using System.Linq;
    
    using MonoTouch.Foundation;
    using MonoTouch.UIKit;
    using MonoTouch.Dialog;
    using System.Diagnostics;
    
    namespace MTDLoginDemo
    {
        [Register ("AppDelegate")]
        public partial class AppDelegate : UIApplicationDelegate
        {
            // class-level declarations
            UIWindow window;
            EntryElement login, password;
    
            public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    		{
    			window = new UIWindow (UIScreen.MainScreen.Bounds);
                       
    			window.RootViewController = new DialogViewController (new RootElement ("Login") {
    				new Section (){
    					(login = new EntryElement ("用户名", "输入用户名", "")),
    					(password = new EntryElement ("密码", "用户密码", "", true))
                    },
    				new Section () {
    //					new StringElement ("登录", delegate{ 
    //						Alert(login.Value+" " +password.Value);
    //					})				
    					new UIViewElement("fdsf",CreateBtn(),true)
                    }
    			});
    
    			window.MakeKeyAndVisible ();
    			return true;
    		}
    
    		private UIButton CreateBtn()
    		{
    			UIButton btn = new UIButton (UIButtonType.RoundedRect);
    			btn.Frame = new System.Drawing.RectangleF (0, 0, 300, 35);
    			btn.SetTitle ("登录", UIControlState.Normal);
    			btn.TouchUpInside += delegate {
    				Alert (login.Value + " " + password.Value);
    				// detail login methord...
    			};
    			return btn;
    		}
    
    		private void Alert(string msg)
    		{
    			UIAlertView av = new UIAlertView ("提示", msg, null, "确定", null);
    			av.Show ();
    		}
        }
    }
    
    


  • 相关阅读:
    一起谈.NET技术,C#特性Attribute的实际应用之:代码统计分析 狼人:
    uploadify+C#实例
    GoldenGate DDL双向复制
    [置顶] Cocos2dx 深入解析系列:以XML文件方式保存用户数据
    打包软件里面安装完打开网页
    [置顶] NYOJ38 布线问题
    IDC:PC 今年第一季度出货量继续下滑趋势,比起去年同期跌了13.9%
    设计模式之组合模式java实现
    Linux C下实现线程池
    [置顶] Unix 网络编程系列05
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3423981.html
Copyright © 2020-2023  润新知