2012-09-23 219 views
1

我有一个iPhone应用程序按钮的自定义视图,我用它作为uitextfield的输入视图。所以当我点击这个按钮时,我想让这个按钮弹出,这样用户就可以看到他们的手指下面,非常像iOS中的默认键盘。有人已经问过类似这样的问题,但没有回答,我已经做了一些研究,但找不到任何东西,所以我再次恭敬地问这个。iphone键盘按钮弹出

回答

0

你必须通过代码创建你想要的行为,模拟默认的键盘设计。 这意味着您必须创建一种方法,在用户触摸按钮/键时显示它在用户的手指下方,以及在用户释放按钮时传递键值并删除虚假视图的方法。

underFingerImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:THE_FAKE_IMAGE]]; 

// Call this at touchDownEvent 
- (void)mimeDefaultKeyboardFirstPart 
{ 
    underFingerImageView.frame = CGRectMake(x, y, width, height); 
    [myKeyboard addSubview:underFingerImageView]; 
} 

// call this at touchUpEvent 
- (void)mimeDefaultKeyboardSecondPart 
{ 
    [underFingerImageView removeFromSuperview]; 

    // Do what you want 
}