想学用C#开发iphone 的就加入 QQ群:178290571 ,让我们共同进步吧!
C# MonoTouch for iphone 开发blog http://blog.youkuaiyun.com/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