I have a UITextField that loads from xib. In it, we consider the methods of the viewDidLoad controllers, I set the font to a user-defined value, which is configured correctly in the .plist file and thatβs it. It displays perfectly, except when it is in edit mode, after which the font switches from my custom font to the default font, which, it seems to me, is Helvetica . This is annoying, and I would like to keep my own font everywhere. I looked around and I do not see an immediate solution, the only thing I tried was to reset the textField.font property in the delegate methods textFieldShouldBeginEditing and textFieldDidBeginEditing , nothing about anything.
Edit: I was asked to enter the code, in fact this is only one line, but here.
- (void)viewDidLoad { [super viewDidLoad];
I also tried resetting the font in two ways:
-(void)textFieldDidBeginEditing:(UITextField *)textField { textField.font = [UIFont fontWithName:@"MyFont" size:18]; } -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField { textField.font = [UIFont fontWithName:@"MyFont" size:18]; return YES; }
This does nothing, the font still changes when editing, but then returns back to the custom font after the keyboard is rejected.
Second edit:
Well, I just did what I probably should have tried before, and used several different font files. Both of these fonts worked fine, but for some reason the custom font file I used causes a problem, even though it works fine in all other situations.
ios objective-c iphone
Devin
source share