C# iphone MontTouch UIPageControl 的使用

想学用C#开发iphone 的就加入 QQ群:178290571 ,让我们共同进步吧!

C# MonoTouch for iphone 开发blog  http://blog.csdn.net/ssihc0/

MonoDevelop 版本:2.8.0

MonoTouch 版本:4.2.2

UIPageControl 为页面控件,向用户提供应用程序中有其他页面的信息。

常用属性:

Pages  分页的总页数;

ValueChanged 事件。分页改的时候触发


下面是方法和属性:



这个control很简单,不多说了,直接上代码

	public partial class PageControlViewController : UIViewController
	{
		UIPageControl pageControl;
		UIView view1,view2,view3;
		public PageControlViewController (string nibName, NSBundle bundle) : base (nibName, bundle)
		{
		}
		
		public override void DidReceiveMemoryWarning ()
		{
			// Releases the view if it doesn't have a superview.
			base.DidReceiveMemoryWarning ();
			
			// Release any cached data, images, etc that aren't in use.
		}
		
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			pageControl= new UIPageControl(new System.Drawing.RectangleF(100,20,100,45));
			pageControl.Pages=3;
			pageControl.ValueChanged += delegate(object sender, EventArgs e) {
				Console.WriteLine ("{0}",pageControl.CurrentPage);
				switch (pageControl.CurrentPage) {
				case 0:
					view1.Hidden=true;
					view2.Hidden=true;
					view3.Hidden=false;
					break;
				case 1:
					view1.Hidden=true;
					view2.Hidden=false;
					view3.Hidden=true;
					
					break;
				case 2:
					view1.Hidden=false;
					view2.Hidden=true;
					view3.Hidden=true;
					break;
				default:
					break;
				}
			};
			view1= new UIView(new System.Drawing.RectangleF(50,100,200,200));
			view2= new UIView(new System.Drawing.RectangleF(50,100,200,200));
		 	view3= new UIView(new System.Drawing.RectangleF(50,100,200,200));
			view1.BackgroundColor=UIColor.Yellow ;
			view2.BackgroundColor=UIColor.Blue;
			view3.BackgroundColor=UIColor.Red;
			this.View.AddSubviews(view1,view2,view3);
			this.View.AddSubview(pageControl);

			//any additional setup after loading the view, typically from a nib.
		}
		
		public override void ViewDidUnload ()
		{
			base.ViewDidUnload ();
			
			// Release any retained subviews of the main view.
			// e.g. myOutlet = null;
		}
		
		public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
		{
			// Return true for supported orientations
			return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown);
		}
	}

运行结果:


源代码:

下载

下载后把gif 改成zip

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值