Xcode font size randomly changes when testing on iPhone - iphone

I am having a problem with a UITextView when building an iPhone app using Xcode 4.6.2 where the font size on a UITextView keeps changing when testing on my iPhone.
I originally set the font size in the storyboard editor and it ran fine, the font size was 14 as expected. Later that day I looked again and the text was bigger (maybe around 20). If I click the back button and select the table cell to go back into the view sometimes it changes back to the normal size. This then keeps changing again and again whenever it wants to.
Having no luck I tried it using the viewcontroller..
In ViewController.h
#property (weak, nonatomic) IBOutlet UITextView * textfield14a;
In ViewController.m
_textfield14a.font = [UIFont systemFontOfSize:14];
Even after setting the font size with code it still changes size randomly. I have searched all over the web and I haven't seen a single article with this same problem.
Has anyone else ever had this? If yes please can you tell me if and how you solved the problem.
Any help is very much appreciated!!!

delete derived data, delete the app off of your simulator or device, clean your project, restart xcode,
if that doesn't work look at the UITextView to make sure it is set to one property or none depending on your situation, if it is a property search the the code to see anywhere if the font is changing
if not then is it a custom font? if so it could be an error with that font, if none of that works then i would need a sample project to witness the error and debug it

check this...
[textView setFont:[UIFont fontWithName:#"ArialMT" size:16]]

Related

UIImageView from Storyboard nil on simulator

I have a quite normally wired UIImageView in a viewController in a StoryBoard. When I run the app on the iPhone it is correctly assigned in the code, while if if I run in the simulator it remains nil thus crashing the constraint trying to locate it. That would not be a big deal, were it not for the need of producing the screenshots for the iPhone 5 I do not own.
All other objects are correctly loaded also on the simulator.
The name is "appending" that I do not think is a reserved word, and I tried also to load a different image in the control with not variation.
What could it be?

Changes made to UI objects are not updating in iPhone simulator

I'm new to objective-c and iPhone, but have done lots of java coding in past.
Tearing hair out about v. basic things which I'm usually eventually able to find answer to, but not this one!
I'm wanting to make a label's background colour change, code below. No matter what I do it doesn't change when I run it on the iPhone simulator. Is there some setting there, I feel like I'm asking a very stupid question but really can't find an answer. Is this a problem with the setup of the development environment??
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSLog(#"setting label to black color");
self.colourLabel.backgroundColor = [UIColor blackColor];
}
Why don't you make an IBOutlet of type UILabel, hook it up to the label in the interface builder and do:
yourLabel.backgroundColor = [UIColor whateverColor];
Did you set colorLabel as a property? Because you wouldn't need to... unless you have two separate classes that you want to communicate with each other.
Remember that in Objective-C sending messages to nil objects is fine, so the problem may be that self.coulourLabel is still nil at that time.
How and where do you instantiate it? Did you set the IBOutlet?
Just thought I'd leave an answer emphasising the suggestion from #Dima in the comments on the question - ie, Project > Clean and then iOS Simulator > Reset Content And Settings.
I just solved a similar problem which was occurring with a UIButton created in code, and so couldn't have been an IBOutlet issue. Changes I made to the code (even deleting the property altogether) weren't showing up when I ran in the simulator, even though on my device it worked fine. I had assumed that doing a clean would be enough but it wasn't until I did the Reset Content And Settings that it started behaving as I expected.
Hope someone finds this useful...

Cocoa Touch UITextView setText: method useless

I have a UITextView which I create in Interface Builder for an iOS app. I checked (and double checked, and triple checked) that it is properly connected to the outlet in my code. I create a property and synthesize it, and when I run NSLog(#"%#", myTextView);, it returns the UITextView's properties, not null. However, when I try calling [myTextView setText:#"My Text."];, it doesn't change anything on the view. I have found many people with similar problems like this on Stackoverflow and other places on the internet, however none of the solutions there helped me. I am using Xcode 4.0.2 on Snow Leopard. I am attempting to do this in the -viewDidLoad method. What could be causing this issue?
If you need any more information about my code setup, post a comment and I will update this post.
Are you sure the whole text view is visible on screen, and that the font color is not the same as your background?
It is very likely that the view that is displayed on the screen is not the same view as myTextView points to. Check [myTextView superview] and make sure it's onscreen. Then look and see if you've accidentally covered it with something. Change other aspects like the backgroundColor. Also, check the frame and make sure it's not CGRectZero.

UINavigationItem#titleView alignment problems

I am finding little information about using UINavigationItem#titleView with a custom font.
When I have done so, the font is misaligned vertically in the navigation bar.
This entry is partly to document a hack, and also hoping someone has a succinct answer to this problem, as I feel I am missing something simple.
First the hack, using my own UILabel derived class:
#interface NavigationItemLabel : UILabel
- (void)setFrame:(CGRect)frame;
#end
#implementation NavigationItemLabel
- (void)setFrame:(CGRect)frame {
// Called by UINavigationBar layoutSubviews.
frame.origin.y -= self.font.descender;
}
#end
For some reason, frame.origin.y == -11, no matter what font I use.
Does anyone have any intuition as to why this is?
Adding my font's descender (custom font called Gabriola) seems to help. Without this hack, the text is aligned with the bottom of the descenders on the center of the navigation bar.
This doesn't work for all fonts.
Does anyone have a better solution?
Thanks.
If you are deploying to iOS 5+, you could check out the titleVerticalPositionAdjustmentForBarMetrics property the in the UINavigationBar documentation:
- (CGFloat)titleVerticalPositionAdjustmentForBarMetrics:(UIBarMetrics)barMetrics
Returns the title’s vertical position adjustment for given bar metrics.
Also, you should check out titleTextAttributes (also iOS5+), which you can use to set a custom font:
NSDictionary *attributes = #{
UITextAttributeFont: yourFont
};
[navBar setTitleTextAttributes:attributes];
If you're NOT on iOS5, I'd suggest wrapping the UILabel inside a UIView and setting your UIView as titleView instead (this allows you to further adjust the wrapped label's position by changing its frame).
If you have access to the WWDC 2012 videos (i.e. if you've got a developer account), I'd strongly recommend watching the talk on Advanced Appearance Customization on iOS (this stuff is included there).
Hope it helps somehow.
I had the same problem using Grotesque and there was a great SO solution shown by #kolyuchiy here. (It involves downloading the Apple Font Tool Suite command line utilities and adjusting the ascender attribute for your custom font).

Changing keyboard layout in UITextField causes memory leak

I have created UITextField in UITableViewCell in my app, and I receive strange memory leak with it.
When I launch my application and tap this UITextField - there is no problem with it. I can type text in English, no leaks at this moment.
But when I press globe button on a keyboard to switch to another language(for instance, Russian), I receive the memory leak in UIKeyboardInputManager, even if I don't type any text in non-english language.
Any ideas?
Tested both in simulator and iphone.
I would assume this is an issue with iOS, not even Apple is perfect. File a bug report with Apple.
http://bugreport.apple.com