I'm trying to set the font size in a UITextField that is created using Interface Builder in the iPhone SDK. I'm new to Cocoa, so there may be something obvious I'm missing.

The first attempt was to set the Min Size from Interface Builder. This does not appear to do anything.

I then attempted to override the init methods in my class that descends from UITextField. The implementation is:

- (id) init {
 UITextField *superObject = [super init];
//  if (superObject != NULL) {
      superObject.font = [UIFont systemFontOfSize:17.0];
//    }
   return superObject;
}

- (id) initWithFrame: (CGRect) aRect {
  UITextField *superObject = [super initWithFrame: aRect];
//  if (superObject != NULL) {
      superObject.font = [UIFont systemFontOfSize:17.0];
//    }
   return superObject;
}

There is a corresponding interface. The line

       superObject.font = [UIFont systemFontOfSize:17.0];

actually does seem to work when I put it in another method, and breakpoints indicate that neither of these initialization methods are called when the text field is created. Either I missed an init method, I don't understand how init methods are supposed to be used, or Interface Builder has a bug--I really thought it was up to the creator of an object to _always_ call one of the init methods.

So there are really two questions here:

1. How do I set the font size for my UITextField before it is displayed?

2. Why is neither init method called?

Thanks in advance,

Mike Westerfield

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to