How to enable/disable a UITextField or UITextView programmatically?

2010-01-13 Thread William Squires
I have a UITableView that's part of a Navigation-based Application.  
There's one .xib, a DrinkDetailViewController class (.m  .h files)  
and an AddDrinkViewController class which inherits from  
DrinkDetailViewController. Both share the same view, which contains a  
UITextField, two UITextViews, and some UILabels. The  
DrinkDetailViewController.h declares three IBOutlets as follows:


#import UIKit/UIKit.h

@interface DrinkDetailViewController : UIViewController
{
IBOutlet UITextField *nameField;
IBOutlet UITextView *ingredientsView;
IBOutlet UITextView *directionsView;
...
}

@end

so that I can access the UITextField, and the two UITextViews. IB  
shows in the inspector window, that the UITextField, and UITextViews  
have a BOOL enabled property (controlled by a checkbox labeled  
Enabled). But the following doesn't work:


...
nameField.enabled = YES;
ingredientsView.enabled = YES;
directionsView.enabled = YES;
...

in the viewDidLoad: method of AddDrinkViewController. I unchecked the  
enabled box for these controls as the normal use of the view is just  
to display drink information, not for data entry. The  
AddDrinkViewController re-uses the view for data entry, and I want to  
re-enable the fields, but only when the view (xib) is used/loaded by  
the AddDrinkViewController. I looked in the docs for UITextField, but  
didn't even see a reference to an enabled property. Is this another  
of those view-within-a-view problems?


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to enable/disable a UITextField or UITextView programmatically?

2010-01-13 Thread Henry McGilton (Boulevardier)

On Jan 13, 2010, at 6:22 PM, William Squires wrote:

 I have a UITableView that's part of a Navigation-based Application. There's 
 one .xib, a DrinkDetailViewController class (.m  .h files) and an 
 AddDrinkViewController class which inherits from DrinkDetailViewController. 
 Both share the same view, which contains a UITextField, two UITextViews, and 
 some UILabels. The DrinkDetailViewController.h declares three IBOutlets as 
 follows:
 
 #import UIKit/UIKit.h
 
 @interface DrinkDetailViewController : UIViewController
 {
 IBOutlet UITextField *nameField;
 IBOutlet UITextView *ingredientsView;
 IBOutlet UITextView *directionsView;
 ...
 }
 
 @end
 
 so that I can access the UITextField, and the two UITextViews. IB shows in 
 the inspector window, that the UITextField, and UITextViews have a BOOL 
 enabled property (controlled by a checkbox labeled Enabled). But the 
 following doesn't work:
 
 ...
 nameField.enabled = YES;
 ingredientsView.enabled = YES;
 directionsView.enabled = YES;
 ...
 
 in the viewDidLoad: method of AddDrinkViewController. I unchecked the enabled 
 box for these controls as the normal use of the view is just to display drink 
 information, not for data entry. The AddDrinkViewController re-uses the view 
 for data entry, and I want to re-enable the fields, but only when the view 
 (xib) is used/loaded by the AddDrinkViewController. I looked in the docs for 
 UITextField, but didn't even see a reference to an enabled property. Is this 
 another of those view-within-a-view problems?

Theenabledproperty is defined in UIControl --- the super-class of 
UITextField . . .

This is a good time for a plug for Xcode's incredibly useful but oft skipped 
over Class Browser,
the second item in Xcode's  Project  menu . . .

Cheers,
. . . . . . . .Henry



=
iPhone App Development and Developer Education . . .
Visit  www.nonatomic-retain.com

Mac OSX Application Development, Plus a Great Deal More . . .
Visit  www.trilithon.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com