2010-08-05 34 views
1

我了解AccessoryViews和测试苹果的例子:KeyBoardAccessory没有键盘的TextView上的AccessoryView?

我试图显示附属视图避免了键盘显示的,但我不能这样做:-(

我米textViewShouldBeginEditing不会回来,避免键盘和返回之前动画TextView的的大小调整,但没有任何反应。

我做错了什么?

- (void)viewWillAppear:(BOOL)animated { 

    // Make the keyboard appear when the application launches. 
    [super viewWillAppear:animated]; 
    [textView becomeFirstResponder]; 
} 

- (BOOL)textViewShouldBeginEditing:(UITextView *)aTextView { 
    NSLog(@"textViewShouldBeginEditing"); 
    /* 
    You can create the accessory view programmatically (in code), in the same nib file as the view controller's main view, or from a separate nib file. This example illustrates the latter; it means the accessory view is loaded lazily -- only if it is required. 
    */ 

    if (textView.inputAccessoryView == nil) { 
     [[NSBundle mainBundle] loadNibNamed:@"AccessoryView" owner:self options:nil]; 
     // Loading the AccessoryView nib file sets the accessoryView outlet. 
     textView.inputAccessoryView = accessoryView;  
     // After setting the accessory view for the text view, we no longer need a reference to the accessory view. 
     self.accessoryView = nil; 
    } 

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1]; 

    textView.frame = CGRectMake(textView.frame.origin.x, textView.frame.origin.y, textView.frame.size.width, textView.frame.size.height - 100); 

    [UIView commitAnimations];  

    return NO; 
} 
+0

你能解释一下你试图深入的结果吗?当您单击文本视图而不是键盘和附件视图时,只需要与键盘相关的配件视图出现? – 2010-08-05 18:37:20

+0

是的,我想只显示配件,但我错了关于要使用的属性,我需要一个inputView – rubdottocom 2010-08-06 10:21:16

回答

1

如果您确实只需要accessoryview,则必须将inputview设置为无高度的视图。

0

在Xcode 6上,ios 8.1 Simulator显示默认情况下隐藏的键盘。 (我必须选择“切换软件键盘”才能显示它。)

我喜欢这一点,因为只有我的辅助视图出现。

我有一种以编程方式复制本(切换键盘上下车,没有解雇)

谢谢!