Not able to disable UITextView

Discussion in 'iOS Programming' started by asifpv, Apr 20, 2009.

  1. macrumors newbie

    Joined:
    Apr 13, 2009
    #1
    Hi All,

    In my view am dynamically calling UITextView or UITextField. After calling any one view , when i call the other view both are displaying..ie. am not able to disable my UITextView( for which i have larger view than UITextField). Anyone knowing this please help me...

    - (void)viewWillAppearBOOL)animated {

    [super viewWillAppear:YES];

    self.title = [self.keyOfTheFieldToEdit capitalizedString];

    NSString* kk = self.keyOfTheFieldToEdit;

    if(kk == @"firstName" || kk == @"lastName" || kk == @"email") {

    CGRect frame = CGRectMake(20.0, 68.0, 280.0, 31.0);
    UITextField *aTextField = [[UITextField alloc] initWithFrame:frame];
    self.textField2 = aTextField;
    [aTextField release];
    textField2.textAlignment = UITextAlignmentCenter;
    textField2.borderStyle = UITextBorderStyleRoundedRect;
    textField2.autocapitalizationType = UITextAutocapitalizationTypeWords;
    textField2.keyboardType = UIKeyboardTypeNamePhonePad;
    textField2.returnKeyType = UIReturnKeyDone;
    textField2.delegate = self;
    [self.view addSubview:textField2];

    textField2.text = self.editValue;

    [textField2 becomeFirstResponder];

    }
    else if(kk == @"note") {

    self.textField2.enabled = NO;

    CGRect frame = CGRectMake(20.0, 60.0, 280.0, 120.0);
    UITextView *aTextView = [[UITextView alloc] initWithFrame:frame];
    self.textView = aTextView;
    [aTextView release];
    textView.backgroundColor = [UIColor whiteColor];
    textView.keyboardType = UIKeyboardTypeNamePhonePad;
    textView.returnKeyType = UIReturnKeyDone;
    textView.delegate = self;
    [self.view addSubview:textView];

    textView.text = self.editValue;

    [textView becomeFirstResponder];
    }

    here after calling my else if part, when we call if part both are displaying...

    when we call else if part after if ,then it is overlapping, so in view there is no problem..

    Asif
     
  2. macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #2
    Code:
    view.enabled = NO;
    doesn't stop views from appearing, it just prevents the user interacting with them. You want:

    Code:
    view.hidden = YES
     
  3. thread starter macrumors newbie

    Joined:
    Apr 13, 2009
    #3
    Hi Jnic,

    Thanx for your reply, can you pleas explain how can i dynamically make my UITextView or UITextField hidden. Now after i giving view.hidden = YES , my view not displaying anything...please help me..

    ie. based on my selection (firstName, lastName, or note) from one view i want to display in my editView TexField or textView.

    thanks,
    asif
     
  4. macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #4
    I meant "view" as a placeholder for whatever you want to hide, for intance:

    Code:
    textView.hidden = YES;
    would hide your text view, etc.
     
  5. thread starter macrumors newbie

    Joined:
    Apr 13, 2009
    #5
    Hi Jnic,

    Thanks a lot...Its working fine..

    Thanx,
    asif
     

Share This Page