2012-05-04 12 views
7

Peki, bu soruyu göndermeden önce iyi bir göz atmaya başladım, ancak doğru yanıtları bulmakta başarısız oldum. Tüm uygulama senaryosunu gerçekten açıklayamayacağım çünkü açıklamak biraz karmaşık. Öyleyse, bu soruyu çok basit yapalım. UIKeyBoard.i.e'nin çerçevesini nasıl değiştirebilirim. Görünüm konumumu desteklemek için UIKeyBoard'un 90 derece yukarı veya çevirmesini istiyorum. Benim için bir çıkış yolu var mı?UIKeyBoard çerçevesini iOS'ta nasıl değiştirebilirim?

+0

ios5'de bu şey kullanılabilir. Wwdc2011 dosyasına bakın. – vishiphone

+0

im ios 4.2 ve üzeri tüm aygıtları desteklemesi gerekiyordu :( –

+0

Ama bence bu daha fazla karmaşık Buddy hakkında üzgünüm bilmiyorum – vishiphone

cevap

4

Varsayılan klavyeyi değiştiremezsiniz. Bununla birlikte, örneğin bir UITextField üzerinde inputView olarak ayarlayarak klavye değiştirme olarak kullanılacak özel bir UIView oluşturabilirsiniz.

Özel bir klavye oluştururken biraz zaman alır, eski iOS sürümleriyle iyi çalışır (UITextField üzerindeki inputView, iOS 3.2 ve sonraki sürümlerde kullanılabilir) ve fiziksel klavyeleri destekler (klavyenin bağlanması durumunda otomatik olarak gizlenir) . Bazı UIViewController özel klavye kullanma

#import "CustomKeyboardView.h" 

@implementation CustomKeyboardView 

@synthesize innerInputView=_innerInputView; 
@synthesize underlayingView=_underlayingView; 

- (id)initForUnderlayingView:(UIView*)underlayingView 
{ 
    // Init a CustomKeyboardView with the size of the underlying view 
    // You might want to set an autoresizingMask on the innerInputView. 
    self = [super initWithFrame:underlayingView.bounds]; 
    if (self) 
    { 
     self.underlayingView = underlayingView; 

     // Create the UIView that will contain the actual keyboard 
     self.innerInputView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, underlayingView.bounds.size.height)]; 

     // You would need to add your custom buttons to this view; for this example, it's just red 
     self.innerInputView.backgroundColor = [UIColor redColor]; 

     [self addSubview:self.innerInputView]; 
    } 
    return self; 
} 

-(id)hitTest:(CGPoint)point withEvent:(UIEvent *)event 
{ 
    // A hitTest is executed whenever the user touches this UIView or any of its subviews. 

    id hitTest = [super hitTest:point withEvent:event]; 

    // Since we want to ignore any clicks on the "transparent" part (this view), we execute another hitTest on the underlying view. 
    if (hitTest == self) 
    { 
     return [self.underlayingView hitTest:point withEvent:nil]; 
    } 

    return hitTest; 
} 

@end 

:

Arabirim:

#import <UIKit/UIKit.h> 

@interface CustomKeyboardView : UIView 

@property (nonatomic, strong) UIView *innerInputView; 
@property (nonatomic, strong) UIView *underlayingView; 

- (id)initForUnderlayingView:(UIView*)underlayingView; 

@end 

Uygulama İşte

dikey klavye oluşturmak için bazı örnek kod var

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    CustomKeyboardView *customKeyboard = [[CustomKeyboardView alloc] initForUnderlayingView:self.view]; 
    textField.inputView = customKeyboard; 
} 
+0

Harika sesler .. Bunu deneyeyim ... BTW +1 :) –

İlgili konular