• 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



  • 相关阅读:
    C++ 的查漏补缺
    Model元数据解析
    Controller
    路由
    win8系统 Reflect 破解
    MVC运行原理
    源代码Log
    linq 分类
    EF 实体关系
    第二十六章 计算限制的异步操作
  • 原文地址:https://www.cnblogs.com/foxmin/p/2393625.html
Copyright © 2020-2023  润新知