TextView KeyBoard Problem

Discussion in 'iOS Programming' started by andyiapan, Nov 27, 2010.

  1. andyiapan macrumors newbie

    Joined:
    Feb 28, 2010
    #1
    TextView KeyBoard Problem
    i design some buttons for inputting on textview,

    but when i press on textview, a default QWERTY keyboard loaded><

    i try to disabled it, but i can't modify textview content anymore.

    how can i modify textview content and not display QWERTY keyboard.

    Thanks~
     
  2. ViviUO macrumors 6502

    Joined:
    Jul 4, 2009
    #2
    What kind of keyboard do you want to use? You can change the type of keyboard for a specific UITextField or UITextView in it's properties inspector in Interface Builder.
     
  3. andyiapan thread starter macrumors newbie

    Joined:
    Feb 28, 2010
    #3
    i don't want any keyboard when i touch on textview but i can still modify textview content by my UIbutton~~
     
  4. yaniv92648, Nov 28, 2010
    Last edited by a moderator: Dec 2, 2010

    yaniv92648 macrumors member

    Joined:
    Oct 26, 2009
    #4
    Solution

    Code:
    txtView.userInteractionEnabled = YES;
    txtView.editable = YES;
    
    use UITextViewDelegate method:
    Code:
    - (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    	return fromButton;
    }
    
    define the button click method:
    Code:
    - (void)buttonClicked{
    fromButton = YES;
    [txtView becomeFirstResponder];
    // u'r code
    fromButton = NO;
    }
    
    GoodLuck!
     
  5. andyiapan, Dec 2, 2010
    Last edited by a moderator: Dec 2, 2010

    andyiapan thread starter macrumors newbie

    Joined:
    Feb 28, 2010
    #5

    how can i disable it><
    Code:
    - (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    	return fromButton;
    }
     
  6. yaniv92648 macrumors member

    Joined:
    Oct 26, 2009
    #6
    fromButton

    fromButton is an ivar which is set to NO at the beginning.
     
  7. andyiapan, Dec 2, 2010
    Last edited by a moderator: Dec 2, 2010

    andyiapan thread starter macrumors newbie

    Joined:
    Feb 28, 2010
    #7
    an naive question~

    do i need to call
    Code:
    - (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    return fromButton;
    }
    
    this function in button click??
     
  8. yaniv92648, Dec 2, 2010
    Last edited by a moderator: Dec 2, 2010

    yaniv92648 macrumors member

    Joined:
    Oct 26, 2009
    #8
    UITextViewDelegate

    This line:
    Code:
    [textView becomeFirstResponder];
    
    calls the delegate method:
    Code:
    - (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    }
    
    4 more information read UITextViewDelegate
     

Share This Page