Created
November 24, 2014 16:31
-
-
Save benjaminsnorris/25440b5223c805f7b897 to your computer and use it in GitHub Desktop.
Resized Picker View
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.m | |
// test | |
// | |
// Created by Joshua Howland on 11/21/14. | |
// Copyright (c) 2014 Wired In LLC. All rights reserved. | |
// | |
#import “ViewController.h” | |
@interface ViewController () <UIPickerViewDataSource, UIPickerViewDelegate> | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 150, 88)]; | |
pickerView.delegate = self; | |
pickerView.dataSource = self; | |
[self.view addSubview:pickerView]; | |
} | |
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component { | |
return 33; | |
} | |
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component { | |
return 65; | |
} | |
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { | |
return 2; | |
} | |
// returns the # of rows in each component.. | |
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { | |
return 3; | |
} | |
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { | |
NSArray *hours = @[@“1h”, @“2h”, @“3h”]; | |
NSArray *minutes = @[@“0m”, @“1m”, @“2m”]; | |
if (component == 0) { | |
return hours[row]; | |
} else { | |
return minutes[row]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment