Using Xcode 6 with iOS 8 SDK and the minimum supported as iOS 7.
This code does not work on iPhone 5s 8.0, iPhone 6, iPhone 6 Plus, but it does work on iPhone 5 8.0 and iPhone 4s 8.0.
It has one text field. The text field has an inputView and inputAccessoryView to show a date picker and toolbar with one button.
I only did enough to demonstrate the issue. On those higher model simulators, only the toolbar is shown and not the picker.
Is this a bug in the simulator or a change in iOS 8 that still kinda works?
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 43, 320, 480)];
pickerView.delegate = self;
pickerView.dataSource = self;
[pickerView setShowsSelectionIndicator:YES];
pickerView.backgroundColor = [UIColor whiteColor];
_textField.inputView = pickerView ;
_textField.delegate = self;
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 56)];
toolbar.barStyle = UIBarStyleBlackOpaque;
[toolbar sizeToFit];
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[barItems addObject:flexSpace];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:nil];
[barItems addObject:doneBtn];
[toolbar setItems:barItems animated:YES];
_textField.inputAccessoryView = toolbar;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return 3;
}
@end