4

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
Jason Hocker
  • 6,879
  • 9
  • 46
  • 79

3 Answers3

4

Check your iOS Simulator's hardware keyboard status. In the iOS Simulator menu bar, go to Hardware > Keyboard and unselect the Connect Hardware Keyboard option.

Kumar Summan
  • 236
  • 2
  • 4
0

Whenever you have a textfield in focus and the keyboard is not appearing, try on your physical keyboard command+k or Hardware > Keyboard > Toggle Software Keyboard from the top bar on your mac when the simulator is the focus window.

Kris Gellci
  • 9,539
  • 6
  • 40
  • 47
0

You can change toolbar style to default and check. It works for me.

Sam
  • 1