第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何以編程方式檢查iOS應(yīng)用程序中是否存在鍵盤?

如何以編程方式檢查iOS應(yīng)用程序中是否存在鍵盤?

iOS
BIG陽 2019-11-08 14:22:00
我需要在我的iOS應(yīng)用中檢查鍵盤可見性的條件。偽代碼:if(keyboardIsPresentOnWindow) {    //Do action 1}else if (keyboardIsNotPresentOnWindow) {    //Do action 2}如何檢查這種情況?
查看完整描述

3 回答

?
LEATH

TA貢獻1936條經(jīng)驗 獲得超7個贊

…或采取簡單的方法:


輸入textField時,它成為第一響應(yīng)者,并出現(xiàn)鍵盤。您可以使用來檢查鍵盤的狀態(tài)[myTextField isFirstResponder]。如果返回YES,則鍵盤處于活動狀態(tài)。


查看完整回答
反對 回復(fù) 2019-11-08
?
函數(shù)式編程

TA貢獻1807條經(jīng)驗 獲得超9個贊

drawonward的代碼非常接近,但與UIKit的命名空間沖突,因此可以更易于使用。


@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


查看完整回答
反對 回復(fù) 2019-11-08
?
繁花不似錦

TA貢獻1851條經(jīng)驗 獲得超4個贊

UIKeyboardListener當(dāng)您知道鍵盤不可見時,請創(chuàng)建一個,例如通過[UIKeyboardListener shared]從調(diào)用applicationDidFinishLaunching。


@implementation UIKeyboardListener


+ (UIKeyboardListener) shared {

    static UIKeyboardListener sListener;    

    if ( nil == sListener ) sListener = [[UIKeyboardListener alloc] init];


    return sListener;

}


-(id) init {

    self = [super init];


    if ( self ) {

        NSNotificationCenter        *center = [NSNotificationCenter defaultCenter];

        [center addObserver:self selector:@selector(noticeShowKeyboard:) name:UIKeyboardDidShowNotification object:nil];

        [center addObserver:self selector:@selector(noticeHideKeyboard:) name:UIKeyboardWillHideNotification object:nil];

    }


    return self;

}


-(void) noticeShowKeyboard:(NSNotification *)inNotification {

    _visible = true;

}


-(void) noticeHideKeyboard:(NSNotification *)inNotification {

    _visible = false;

}


-(BOOL) isVisible {

    return _visible;

}


@end


查看完整回答
反對 回復(fù) 2019-11-08
  • 3 回答
  • 0 關(guān)注
  • 538 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號