Created
February 17, 2015 22:36
-
-
Save chrislerum/0b1a85450c7fb87edf63 to your computer and use it in GitHub Desktop.
app starts fine, tap button and picker shows, start to scroll picker, immediate crash
This file contains 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
class MainViewController < UIViewController | |
def viewDidLoad | |
show_picker_button = UIButton.buttonWithType UIButtonTypeRoundedRect | |
show_picker_button.setTitle "Show Year Picker", forState: UIControlStateNormal | |
show_picker_button.frame = [[100, 100], [100, 50]] | |
show_picker_button.addTarget(self, | |
action: :show_year_picker, | |
forControlEvents: UIControlEventTouchUpInside) | |
self.view.addSubview show_picker_button | |
end | |
def show_year_picker | |
year_picker = YearPickerViewController.new | |
self.view.addSubview year_picker.view | |
end | |
end |
This file contains 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
class YearPickerViewController < UIViewController | |
def viewDidLoad | |
picker = UIPickerView.new | |
picker.backgroundColor = UIColor.whiteColor | |
picker.delegate = self | |
picker.dataSource = self | |
picker.showsSelectionIndicator = true | |
self.view.addSubview picker | |
end | |
def numberOfComponentsInPickerView pickerView | |
1 | |
end | |
def pickerView(pickerView, numberOfRowsInComponent:component) | |
50 | |
end | |
def pickerView(pickerView, titleForRow:row, forComponent:component) | |
(2000 + row).to_s | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment