2014-09-18 13 views
5

Mam dziwny błąd, który występuje tylko w symulatorze iPhone 6 w Xcode 6. Mam ogólny komponent, który rozszerza UITextField i pokazuje pickerView jako inputView na dole ekranu.Wejście UITextFieldView nie wyświetla się w iPhone 6

Jeśli używam iPhone5 lub iPhone5s do przetestowania aplikacji, działa ona zgodnie z oczekiwaniami: inputView i inputAccessoryView są wyświetlane poprawnie. Ale jeśli przejdę do symulatora iPhone 6 lub Plus, tylko u dołu ekranu pojawi się inputAccessoryView, inputView nie wyświetla się.

Oto mój kod:

@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; 
} 

Czy ktoś natknąć się takim problemem? Jakieś pomysły do ​​rozwiązania?

PS: Próbowałem już oczyścić katalog kompilacji, projekt czyszczenia/przebudowy, symulator zatrzymania/ponownego uruchomienia i metody kodowania xcode. Nie działa.

Odpowiedz

11

spróbuj odznaczyć symulator -> Akcesoria -> Klawiatura -> podłączenie klawiatury sprzętowej

+2

co szybkie i precyzyjne odpowiedzi! dziękuję :) – serdar

+0

Dzięki za udzielenie odpowiedzi – dineshprasanna

Powiązane problemy