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ş:
Nasıl bir görüntü iPhone programlama y...
iphone - programlama yoluyla gezinti k...
nasıl yapılır programlama yoluyla &quo...
Nasıl iPhone SDK üzerinde etkin bir İn...
Nasıl bir iphone uygulaması beta test ...