iPhone控件之UIPickerView

1 #import <UIKit/UIKit.h>
2
3 @interface UITestViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate>
4 {
5
6 }
7
8 @end
 1 //
2 // UITestViewController.m
3 // UITest
4 //
5
6 #import "UITestViewController.h"
7
8 @implementation UITestViewController
9
10 - (void)viewDidLoad {
11
12 [super viewDidLoad];
13
14 CGRect pickerFrame = CGRectMake(0,120,0,0);
15
16 UIPickerView *myPicker = [[UIPickerView alloc] initWithFrame:pickerFrame];
17 myPicker.dataSource = self;
18 myPicker.delegate = self;
19 myPicker.showsSelectionIndicator = YES;
20
21 [self.view addSubview:myPicker];
22
23 [myPicker release];
24 }
25
26 - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
27
28 return 1;
29 }
30
31 - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
32
33 return 10;
34 }
35
36 - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
37
38 return [NSString stringWithFormat:@"Row %i",row];
39 }
40
41 - (void)didReceiveMemoryWarning {
42 // Releases the view if it doesn't have a superview.
43 [super didReceiveMemoryWarning];
44
45 // Release any cached data, images, etc that aren't in use.
46 }
47
48 - (void)viewDidUnload {
49 // Release any retained subviews of the main view.
50 // e.g. self.myOutlet = nil;
51 }
52
53
54 - (void)dealloc {
55 [super dealloc];
56 }
57
58 @end



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值