Initializing font size in UITextField
Initializing font size in UITextField
- Subject: Initializing font size in UITextField
- From: Mike Westerfield <email@hidden>
- Date: Sun, 15 Jun 2008 16:30:29 -0600
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 (email@hidden)
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:
This email sent to email@hidden