{"id":578,"date":"2014-06-09T10:20:44","date_gmt":"2014-06-09T02:20:44","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=578"},"modified":"2016-07-15T15:31:51","modified_gmt":"2016-07-15T07:31:51","slug":"ios%e9%80%89%e6%8b%a9%e5%99%a8%e6%8e%a7%e4%bb%b6uipickerview%e6%9c%80%e7%ae%80%e5%8d%95%e7%9a%84%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/project\/2014\/06\/09\/102044578.html","title":{"rendered":"iOS\u9009\u62e9\u5668\u63a7\u4ef6(UIPickerView)\u6700\u7b80\u5355\u7684\u5b9e\u73b0"},"content":{"rendered":"<p><strong>1\u3001\u4e0a\u56fe\u770b\u6548\u679c<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2016\/07\/\u5c4f\u5e55\u5feb\u7167-2014-06-09-\u4e0a\u534810.14.21.png\" alt=\"\u5c4f\u5e55\u5feb\u7167 2014-06-09 \u4e0a\u534810.14.21\" width=\"300\" height=\"550\" class=\"alignnone size-full wp-image-579\" \/><\/p>\n<p><strong>2\u3001\u5173\u952e\u4ee3\u7801<\/strong><\/p>\n<pre lang=\"objc\" line=\"1\">@implementation ViewController\n\n- (void)viewDidLoad\n{\n    [super viewDidLoad];\n    \n    \/\/ \u8bbe\u7f6e\u80cc\u666f\u8272\u4e3a\u9b44\n    self.view.backgroundColor = [UIColor whiteColor];\n    \n    \/\/ \u521b\u5efa\u4e00\u4e2a\u9009\u62e9\u5668\n    UIPickerView *picker = [[UIPickerView alloc] init];\n    picker.delegate = self;                 \/\/ \u4ee3\u7406\n    picker.dataSource = self;               \/\/ \u6570\u636e\u6e90\n    picker.showsSelectionIndicator = YES;   \/\/ \u9009\u62e9\u884c\u9ad8\u4eae\n    [self.view addSubview:picker];          \/\/ \u6dfb\u52a0\u5230\u89c6\u56fe\n}\n\n#pragma mark - \u6570\u636e\u6e90\u65b9\u6cd5\n#pragma mark \u9009\u62e9\u5668\u7684\u9009\u9879\u5217\u6570\n- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView\n{\n    return 3;\n}\n\n#pragma mark \u9009\u62e9\u5668\u6bcf\u5217\u7684\u9009\u9879\u4e2a\u6570\n- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component\n{\n    return 5;\n}\n\n#pragma mark \u6bcf\u4e2a\u9009\u9879\u7684\u503c\n- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component\n{\n    switch (component) {\n        case 0:\n            return @\"\u7b2c0\u5217\";\n            break;\n            \n        case 1:\n            return @\"\u7b2c1\u5217\";\n            break;\n            \n        default:\n            return @\"\u7b2c2\u5217\";\n            break;\n    }\n}\n@end<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u4e0a\u56fe\u770b\u6548\u679c 2\u3001\u5173\u952e\u4ee3\u7801 @implementation ViewController &#8211; (void)viewDidLoad { [super viewDidLoad]; \/\/ \u8bbe\u7f6e\u80cc\u666f\u8272\u4e3a\u9b44 self.view.backgroundColor = [UIColor whiteColor]; \/\/ \u521b\u5efa\u4e00\u4e2a\u9009\u62e9\u5668 UIPickerView *picker = [[UIPickerView alloc] init]; picker.delegate = self; \/\/ \u4ee3\u7406 picker.dataSource = self; \/\/ \u6570\u636e\u6e90 picker.showsSelectionIndicator = YES; \/\/ \u9009\u62e9\u884c\u9ad8\u4eae [self.view addSubview:picker]; \/\/ \u6dfb\u52a0\u5230\u89c6\u56fe } #pragma mark &#8211; \u6570\u636e\u6e90\u65b9\u6cd5 #pragma mark \u9009\u62e9\u5668\u7684\u9009\u9879\u5217\u6570 &#8211; (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[20],"class_list":["post-578","post","type-post","status-publish","format-standard","hentry","category-project","tag-basics"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/578","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=578"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/578\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}