Xib taking long time (>1s) to load. UIFont cache seems to blame - ios

I have a UIVC loading from a Storyboard which, in turn, loads a Xib. This inner load is causing the VC to take more than a second to load. There is some fancy footwork going on in the inner xib (it loads another xib which has dynamic drawing) but this doesn't appear to be the bottleneck.
According to Instruments, UIFont -initWithCoder is the culprit. (If you drill down further TBaseFont::CopyLocalizedName() is the deepest entry that accounts for the majority of the 1s time)
I'm a bit stumped as the custom font I use occurs all throughout the app with no problems. Any ideas?

Ok the problem was that the custom font was no longer embedded in the app. I had switched to another similar one which looked the same. Weird though as I'd have expected those offending labels to revert back the System font on the device but they did not. Is it possible they were being pulled from the Macbook?

Similar issue here — Hari and gbk hinted me on the right direction.
I found we were using Lucida Grande in one little hidden place (thank you grep), but Lucida Grande is NOT embedded in iOS. I just replaced Lucida Grande with Helvetica Neue, and I gained 3+ seconds at launch time. Impressive.

Had the similar problem - in my case another dev in team just use one more type of font so after merge system cant figure out font and change it for default one - it's take from 1200ms to 2300ms.
Solution - re-setup all fonts on ViewController that cause some freeze.

Related

Swift - Strange text rendering at runtime

I am working on an iOS app right now. I usually use the Interface Builder and recently it has been producing an issue. When the storyboard is seen in Xcode the labels on everything look fine, but some UI elements don't render properly at runtime. This has also happened for some of the images in this project. The only font used is the system font.
I have tried readjusting the font and using attributed text, but this hasn't worked for the specific label shown. Just to mention, this app is a shared project through Git so it may be an issue with it pulling incorrectly or something, but that seems odd for it to affect the text after it has been changed and adjusted.
View post on imgur.com
The results should be crystal clear text on iOS, but it results in "fuzzy" text you would expect if you were running the Windows XP on a 480p screen. What could be causing this issue?
It seems like the layer of a superview of the UILabel in the provided image is set to pre-render. This is good for performance reasons but may not always look as good, as is seen here.
If you're setting a custom layer on a superview of the UILabel, try setting the layer's shouldRasterize to false.
Ex: exampleLayer.shouldRasterize = false

uppercase label in xcode storyboard not wanted

I'm using xcode 6 with storyboard for ios app development.
I have a problem with UILabel in view controllers in storyboard: the text is simple and inlower case, but when I run the app in the simulator or in the device I see the Label text in UPPERCASE.
Labels have no outlets, and cannot be modified programmatically.
some one has a solution? I'd prefer not using IBOutlet and setting text by code..
I had somewhat similar problem. In my case everything(title, lables, button texts, etc.) was in upper case. I found out that "Localization Debugging" was on, so when I had language on iphone which was not supported by localization, it turned words automatically to upper case. When I disabled it, everything worked fine again.
Just go to "Product > Scheme > Edit Scheme" and there select "Run" and disable "Localization Debugging". (Sorry, I don't have enough reputation to post images, otherwise I would put here screen)
Hope it helps
I answer myself fot other people.
Nothing to do with this strange thing. It seems a xcode bug. Sometimes the labels appears uppercased, other times are ok.
I discover a trick that was using the attributed text in storyboard. in this way it works correctly.
Another way is to use a outlet and setting the uilabel.text by code.
Bye

xcode Interface Builder background color preference

It seems odd, so i am likely just missing it in preferences, but how does one change the actual background color of IB in Xcode? Not any of the elements, but the actual blinding white of the standard IB? Too much contrast and when you zoom out, the view controllers almost disappear..
Thanks for any tips..
I've gone ahead and created an Xcode plugin that changes the background color of the storyboard editor. You can find the source at rpendleton/xcode-canvas-color. I've hardcoded it to a light gray color, as shown in the screenshot below, but this can be changed easily.
(Also, I don't think you're missing a setting for it. When I decompiled Xcode, the drawRect method for the background view explicitly called [[NSColor whiteColor] set].)
One doesn’t. Submitting a feature request to Apple is your only hope.
Unfortunately, with recent changes to Xcode, Ryan Pendleton's plugin is no longer a viable option. (unless you are willing to break Xcode's code signing, which can be quite problematic.) However, the good news is that there is now an official solution -- so long as you are willing to upgrade to OS X 10.14 Mojave: Upgrade to OS X 10.14 Mojave and turn on Dark mode. When Dark Mode is enabled, the background in Interface Builder darkens to a nice, eye-pleasing dark gray color. Navigating around a large storyboard is now MUCH easier (and less eye-scorching :) )
Before:
After:

How to cache or preload SKLabelNode font?

I'm making a Sprite Kit app and in my scene I added an SKLabelNode. I noticed a pretty large lag-spike when I load the SKScene. After profiling the app I found it came from creating an SKLabelNode with a papyrus font(though the font doesn't matter). When I remove the label the scene starts up almost instantaneously, but with the label it takes an extra 1-3 seconds.
I am pretty sure it's from loading the font as when I go back to the main menu and play the game again it starts up instantly again.
Now is there a way to preload the font earlier so when the player selects the level there isn't a large pause?
We had this issue, and it turned out that we were simply not using the "correct" font name. In our case, we were using "Menlo" instead of "Menlo-Regular" when instantiating our SKLabelNode, and it was incurring the several-second penalty. Once we used the correct font name, the delay no longer happened.
(Curiously, the SKLabelNode still found Menlo and used it, so it was not immediately obvious that we had the wrong font name. Presumably, the delay is caused by the system having to figure out the appropriate substitute to use. It does a good job, finding the font we intended to use, but it takes a while to do it, hence the delay.)
I had the same issue. Add following code to your very first scene, with your font name:
SKLabelNode *preload = [SKLabelNode labelNodeWithFontNamed:#"Avenir"];
preload.text = #"text";
If you don't provide text it won't load font. Note that you don't need to add label as child to your scene.

UITextView: Link detection working within Simulator, not on device

I've got two UITextViews containing data that should be recongised by the data detection, however whilst one works fine on both device and simulator there's one that only works under Simulator. I've attempted trashing the build from my device, cleaning the product down, removing derived data and nothing seems to resolve the inconsistency.
Link detection was enabled within Interface Builder, the data is passed in with a NSString stringWithFormat: formatted string and set with UITextView setText:. Set the same way for both, so there's no difference there, but it just doesn't seem to work correctly for one of them.
EDIT: On the device if I tap on one of the items that should detect as a link, it'll then turn blue and do link detection. I'm not setting any custom fonts or colours that could have an impact.
It appears that the trick is to setScrollable:NO. Seems to fix the problem, although if you need scrolling, I'm not sure what the answer will be...
Apparently this issue is caused by how iOS is currently handling the UITextView links. It is creating an NSAttributedString that turns sections of the text blue ( when the view contains a link ). So I've figured out that this bug only occurs when a link is the first text in the AttributedString, i.e. the first text in the text view. So it's easily fixed by prepending an whitespace to your text before setting it. Or overriding setText to " " + text;
Hope this helps guys

Resources