2014-12-13 57 views
0

我正在自定義鍵盤上工作正常,但面臨奇怪的問題。我覺得,當我按我的自定義鍵盤上的任意鍵(如果沒有完全訪問權限),它將觸發事件與一些delay.here是我的代碼iOS鍵盤擴展:工作太多,如果沒有完全訪問

- (void)viewDidLoad 
    { 
    [super viewDidLoad]; 
    [self addGestureTokeybaord]; 
    } 
-(void)addGestureTokeybaord 
{ 
    [self.keyboard.deletekey addTarget:self action:@selector(pressDeletekey) forControlEvents:UIControlEventTouchUpInside]; 
    [self.keyboard.spacekey addTarget:self action:@selector(pressSpacekey) forControlEvents:UIControlEventTouchUpInside]; 
    [self.keyboard.returnkey addTarget:self action:@selector(pressReturnkey) forControlEvents:UIControlEventTouchUpInside]; 
    [self.keyboard.donekey addTarget:self action:@selector(dismissKeyboard) forControlEvents:UIControlEventTouchUpInside]; 

    [self.keyboard.globalkey addTarget:self action:@selector(advanceToNextInputMode) forControlEvents:UIControlEventTouchUpInside]; 




    [self.keyboard.shiftkey addTarget:self action:@selector(unShift) forControlEvents:UIControlEventTouchUpInside]; 
    [self.keyboard.shiftkeyright addTarget:self action:@selector(unShift) forControlEvents:UIControlEventTouchUpInside]; 

    [self.keyboard.numberskey addTarget:self action:@selector(pressNumberskey) forControlEvents:UIControlEventTouchUpInside]; 

    for (UIButton *key in self.keyboard.keysArray) { 
     [key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside]; 
    } 
} 
-(void)pressKey:(UIButton *)key 
{ 
    [[UIDevice currentDevice] playInputClick]; 
    [self.textDocumentProxy insertText:[key currentTitle]]; 
} 

我怎麼能激發我的事件沒有任何延遲(如果沒有完全訪問權限)?任何建議將不勝感激。 謝謝

回答

0
[[UIDevice currentDevice] playInputClick]; 

讓你延遲。 只需用完整的訪問檢查進行包裝。