• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Initializing font size in UITextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Initializing font size in UITextField
      • From: Omar Qazi <email@hidden>
    • Re: Initializing font size in UITextField
      • From: Dave Camp <email@hidden>
  • Prev by Date: Re: How can an object know when another object has gone away?
  • Next by Date: Re: Initializing font size in UITextField
  • Previous by thread: Re: How can an object know when another object has gone away?
  • Next by thread: Re: Initializing font size in UITextField
  • Index(es):
    • Date
    • Thread