PDA

View Full Version : Not able to disable UITextView




asifpv
Apr 20, 2009, 08:21 AM
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



jnic
Apr 20, 2009, 09:06 AM
view.enabled = NO; doesn't stop views from appearing, it just prevents the user interacting with them. You want:

view.hidden = YES

asifpv
Apr 20, 2009, 11:28 PM
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

jnic
Apr 21, 2009, 03:50 AM
I meant "view" as a placeholder for whatever you want to hide, for intance:

textView.hidden = YES;

would hide your text view, etc.

asifpv
Apr 21, 2009, 04:29 AM
Hi Jnic,

Thanks a lot...Its working fine..

Thanx,
asif