Ios UITextField inputView未在iPhone 6中显示

Ios UITextField inputView未在iPhone 6中显示,ios,objective-c,uitextfield,xcode6,inputview,Ios,Objective C,Uitextfield,Xcode6,Inputview,我有一个奇怪的bug,它只发生在Xcode 6的iPhone6模拟器中。我有一个通用组件,它扩展了UITextField,并在屏幕底部显示一个pickerView作为inputView 如果我使用iPhone5或iPhone5s来测试我的应用程序,它会按预期工作:inputView和inputAccessoryView显示正确。但若我切换到iPhone6或Plus模拟器,屏幕底部只会显示inputAccessoryView,而不会显示inputView 这是我的密码: @interface Dr

我有一个奇怪的bug,它只发生在Xcode 6的iPhone6模拟器中。我有一个通用组件,它扩展了UITextField,并在屏幕底部显示一个pickerView作为inputView

如果我使用iPhone5或iPhone5s来测试我的应用程序,它会按预期工作:inputView和inputAccessoryView显示正确。但若我切换到iPhone6或Plus模拟器,屏幕底部只会显示inputAccessoryView,而不会显示inputView

这是我的密码:

@interface DropDownTextField : UITextField

@property (strong,nonatomic) UIPickerView* pickerView;
@property (strong,nonatomic) UIToolbar *toolBar;
@property CGFloat originalFontSize;

@property (nonatomic) id<UIPickerViewDelegate> pickerDelegate;
@property (nonatomic) id<UIPickerViewDataSource> pickerDataSource;

- (CGFloat)requiredFontSize;
- (void)setDropdownMode:(BOOL)enabled;

@end

@implementation DropDownTextField

-(id)initWithCoder:(NSCoder *)aDecoder {
    if(self = [super initWithCoder:aDecoder]) {
        self.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;

        [self setFont:[UIFont mediumRegular]];
        _originalFontSize = self.font.pointSize;

        self.layer.borderWidth = 1.0f;

        CGRect frame = [self frame];

        // rightview dropdown arrow
        UIImageView *dropDownImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, (frame.size.height-8)/2, 14.0f, 8.0f)];
        UIImage *dropDownImage = [UIImage imageNamed:@"DisclosureDown"];
        [dropDownImageView setImage:dropDownImage];
        dropDownImageView.contentMode = UIViewContentModeScaleAspectFit;
        UIView *dropDownView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 25.0f, frame.size.height)];
        [dropDownView addSubview:dropDownImageView];

        self.rightView = dropDownView;
        self.rightViewMode = UITextFieldViewModeAlways;
        [self.rightView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(becomeFirstResponder)]];

        // picker view
        _pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,0,SCREEN_WIDTH,216)];
        _pickerView.showsSelectionIndicator = YES;
        [_pickerView setBackgroundColor:[UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1.0f]];
        self.inputView = _pickerView;

        // picker view toolbar
        _toolBar= [[UIToolbar alloc] initWithFrame:CGRectMake(0,0,SCREEN_WIDTH,44)];
        [_toolBar setBackgroundColor:[UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1.0f]];
        [_toolBar setBarStyle:UIBarStyleBlackTranslucent];

        // to align button to the right
        UIBarButtonItem *flex = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];

        UIBarButtonItem *barButtonDone = [[UIBarButtonItem alloc] init];
        [barButtonDone setTarget:self];
        [barButtonDone setAction:@selector(changeSelectionFromLabel:)];
        [barButtonDone setTitle:NSLocalizedString(@"ok", @"")];
        [barButtonDone setTintColor:[UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1.0f]];
        [barButtonDone setStyle:UIBarButtonItemStylePlain];
        [barButtonDone setTitleTextAttributes:[UIFont pickerTitleTextAttributes] forState:UIControlStateNormal];

        UIBarButtonItem *barButtonCancel = [[UIBarButtonItem alloc] init];
        [barButtonCancel setTarget:self];
        [barButtonCancel setAction:@selector(dismissPickerView:)];
        [barButtonCancel setTitle:NSLocalizedString(@"cancel", @"")];
        [barButtonCancel setTintColor:[UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1.0f]];
        [barButtonCancel setStyle:UIBarButtonItemStylePlain];
        [barButtonCancel setTitleTextAttributes:[UIFont pickerTitleTextAttributes] forState:UIControlStateNormal];

        self.toolBar.items = [[NSArray alloc] initWithObjects:barButtonCancel,flex,barButtonDone,nil];
        self.inputAccessoryView = _toolBar;


    }
    return self;
}
@interface DropDownTextField:UITextField
@属性(强,非原子)UIPickerView*pickerView;
@属性(强,非原子)UIToolbar*工具栏;
@属性CGFloat originalFontSize;
@属性(非原子)id pickerDelegate;
@属性(非原子)id pickerDataSource;
-(CGFloat)所需的字体大小;
-(void)setDropdownMode:(BOOL)已启用;
@结束
@实现DropDownTextField
-(id)initWithCoder:(NSCoder*)aDecoder{
if(self=[super initWithCoder:aDecoder]){
self.contentVerticalAlignment=uicontrol contentVerticalAlignment中心;
self.contentHorizontalAlignment=uicontrol内容HorizontalAlignment右侧;
[self-setFont:[UIFont mediumRegular]];
_originalFontSize=self.font.pointSize;
self.layer.borderWidth=1.0f;
CGRect帧=[自帧];
//右视图下拉箭头
UIImageView*dropDownImageView=[[UIImageView alloc]initWithFrame:CGRectMake(0,(frame.size.height-8)/2,14.0f,8.0f)];
UIImage*dropDownImage=[UIImage ImageName:@“DispositionDown”];
[dropDownImageView设置图像:dropDownImage];
dropDownImageView.contentMode=UIViewContentModeScaleAspectFit;
UIView*dropDownView=[[UIView alloc]initWithFrame:CGRectMake(0,0,25.0f,frame.size.height)];
[dropDownView添加子视图:dropDownImageView];
self.rightView=下拉视图;
self.rightViewMode=UITextFieldViewModeAlways;
[self.rightView addgestureRecognitzer:[[UITapgestureRecognitzer alloc]initWithTarget:self action:@selector(becomeFirstResponder)];
//选择器视图
_pickerView=[[UIPickerView alloc]initWithFrame:CGRectMake(0,0,屏幕宽度,216)];
_pickerView.showsSelectIndicator=是;
[_PickerViewSetBackgroundColor:[UIColor-WithRed:245/255.0绿色:245/255.0蓝色:245/255.0 alpha:1.0f];
self.inputView=\u pickerView;
//选择器视图工具栏
_工具栏=[[UIToolbar alloc]initWithFrame:CGRectMake(0,0,屏幕宽度,44)];
[_工具栏设置背景颜色:[UIColor color with red:229/255.0绿色:229/255.0蓝色:229/255.0 alpha:1.0f];
[_工具栏setBarStyle:uiBarStyleBlack半透明];
//将按钮向右对齐的步骤
UIBarButtonItem*flex=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarbuttonSystemFlexibleSpace目标:自我操作:nil];
uibarbuttoneim*barbuttonone=[[uibarbuttoneim alloc]init];
[BarbuttonOne setTarget:self];
[BarbuttonOne设置操作:@selector(changeSelectionFromLabel:)];
[BarbuttonOne设置标题:NSLocalizedString(@“ok”,@“)];
[BarbuttonOne setTintColor:[UIColor颜色带红色:229/255.0绿色:229/255.0蓝色:229/255.0 alpha:1.0f];
[BarbuttonOne设置样式:UIBarButtonItemStylePlain];
[BarbuttonOne setTitleTextAttributes:[UIFont pickerTitleTextAttributes]用于状态:UIControlStateNormal];
UIBarButtonItem*barButtonCancel=[[UIBarButtonItem alloc]init];
[barButtonCancel设置目标:self];
[barButtonCancel setAction:@selector(dismissPickerView:)];
[barButtonCancel设置标题:NSLocalizedString(@“取消”,@“)];
[barButtonCancel setTintColor:[UIColor WithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1.0f];
[barButtonCancel设置样式:UIBarButtonContimStyleplain];
[barButtonCancel setTitleTextAttributes:[UIFont pickerTitleTextAttributes]用于状态:UIControlStateNormal];
self.toolBar.items=[[NSArray alloc]initWithObjects:barButtonCancel、flex、barbuttonone、nil];
self.inputAccessoryView=\u工具栏;
}
回归自我;
}
有人遇到过这样的问题吗?有什么解决办法吗


PS:我已经尝试过清除构建目录、清理/重建项目、停止/重新启动模拟器和xcode方法。不工作。

尝试取消选中模拟器->硬件->键盘->连接硬件键盘

感谢您提供此答案