几种常用控件的使用方法
2013-09-15 20:36
507 查看
1.UIActivityIndicatorView的使用
UIActivityIndicatorView *activity=[[[UIActivityIndicatorViewalloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]autorelease];
z
[activity setFrame:CGRectMake(150,150, 50, 50)];
[self.window addSubview:activity];
[activity startAnimating];
2. UISlider的使用
UISlider *slider=[[[UISlideralloc] initWithFrame:CGRectMake(100,20, 140,20)] autorelease];
slider.maximumValue=10;
slider.value=5;
[slider addTarget:selfaction:@selector(change:)forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:slider];
-(void)change:(UISlider*)slider
{
NSLog(@"the val is %.2f",slider.value);
}
3.UIPageControl
通常与UIScrollView连用,提示用户当前显示的页数
@property(nonatomic) NSInteger numberOfPages; // default is 0
@property(nonatomic) NSInteger currentPage; // default is 0. value pinned to 0..numberOfPages-1
@property(nonatomic) BOOL hidesForSinglePage; // hide the the indicator if there is only one page. default is NO
sample code:
4.UISegmentedControl
UIActivityIndicatorView *activity=[[[UIActivityIndicatorViewalloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]autorelease];
z
[activity setFrame:CGRectMake(150,150, 50, 50)];
[self.window addSubview:activity];
[activity startAnimating];
2. UISlider的使用
UISlider *slider=[[[UISlideralloc] initWithFrame:CGRectMake(100,20, 140,20)] autorelease];
slider.maximumValue=10;
slider.value=5;
[slider addTarget:selfaction:@selector(change:)forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:slider];
-(void)change:(UISlider*)slider
{
NSLog(@"the val is %.2f",slider.value);
}
3.UIPageControl
通常与UIScrollView连用,提示用户当前显示的页数
@property(nonatomic) NSInteger numberOfPages; // default is 0
@property(nonatomic) NSInteger currentPage; // default is 0. value pinned to 0..numberOfPages-1
@property(nonatomic) BOOL hidesForSinglePage; // hide the the indicator if there is only one page. default is NO
sample code:
UIPageControl *pageControl=[[[UIPageControl alloc] initWithFrame:CGRectMake(0, 50, 329, 30)] autorelease]; pageControl.numberOfPages=10; pageControl.currentPage=3; pageControl.backgroundColor=[UIColor grayColor]; [pageControl addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventValueChanged]; [self.window addSubview:pageControl]; -(void)clicked:(id)sender { UIPageControl *pageControl=(UIPageControl*)sender; NSLog(@"curent val is %d",pageControl.currentPage); }
4.UISegmentedControl
NSArray *array=[NSArray arrayWithObjects:@"hello",@"what",@"search",nil]; UISegmentedControl *segmentControl=[[[UISegmentedControl alloc] initWithItems:array] autorelease]; segmentControl.frame=CGRectMake(0, 40, 300, 40); segmentControl.segmentedControlStyle=UISegmentedControlStyleBordered; segmentControl.selectedSegmentIndex=2; [segmentControl addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventValueChanged]; [self.window addSubview:segmentControl];
相关文章推荐
- 几种常用控件的使用方法
- JavaScript中的String对象的常用方法、文本框对象的常用方法和事件、正则表达式的概念、正则表达式的几种构造方式、RegExp对象使用什么方法匹配正则表达式、
- android 常用控件之 (Spinner )使用方法
- 用Delphi实现文件下载的几种方法(三种使用控件的方法)
- Android常用控件-DatePicker以及对话框的两种使用方法
- #Android#常用控件使用方法
- Five-People:常用控件及其属性(RadioButton,CheckBox,align,margin,padding)使用方法
- 常用界面控件种类和使用方法
- [Android]几种常用控件使用
- 05读书笔记之常用控件的使用方法:
- Android常用控件-DatePicker以及对话框的两种使用方法
- VC 6.0常用控件使用方法介绍
- WdatePicker 日历控件使用方法+基本常用方法
- 常用控件的使用方法
- android常用控件的使用方法
- 2009-04-09技术学习:wicket常用控件使用方法
- WinForm常用的几个控件的简单使用方法
- Android常用控件ImageSwitcher使用方法详解
- 常用控件种类和使用方法
- Android 第五课 常用控件的使用方法(TextView、Button、EditView、 ImageView、 ProgressBar、 ProgressDialog等)