SORU
29 EYLÜL 2009, Salı


Nasıl bir klavye iphone bulunup bulunmadığını programlama yoluyla kontrol uygulaması?

İPhone uygulamam klavye görünürlük durumunu kontrol etmem gerek.

gibi:

if(keyboardIsPresentOnWindow) {
    //Do action 1
}
else if (keyboardIsNotPresentOnWindow) {
    //Do action 2
}

Yardım lütfen. Bu durumu nasıl kontrol edebilirim?

CEVAP
29 EYLÜL 2009, Salı


drawnonward kod çok yakın, ama UİKit ad ile çakışır ve kolay kullanım için yapılmış olabilir.

@interface KeyboardStateListener : NSObject {
    BOOL _isVisible;
}
  (KeyboardStateListener *)sharedInstance;
@property (nonatomic, readonly, getter=isVisible) BOOL visible;
@end

static KeyboardStateListener *sharedInstance;

@implementation KeyboardStateListener

  (KeyboardStateListener *)sharedInstance
{
    return sharedInstance;
}

  (void)load
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    sharedInstance = [[self alloc] init];
    [pool release];
}

- (BOOL)isVisible
{
    return _isVisible;
}

- (void)didShow
{
    _isVisible = YES;
}

- (void)didHide
{
    _isVisible = NO;
}

- (id)init
{
    if ((self = [super init])) {
        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
        [center addObserver:self selector:@selector(didShow) name:UIKeyboardDidShowNotification object:nil];
        [center addObserver:self selector:@selector(didHide) name:UIKeyboardWillHideNotification object:nil];
    }
    return self;
}

@end

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Marissah Simonini

    Marissah Sim

    25 HAZİRAN 2013
  • Tire Rack

    Tire Rack

    31 Mayıs 2007
  • Troy Hunt

    Troy Hunt

    29 EYLÜL 2011