Swift iOS localization - not all strings in main.strings (xcode 6.3) - ios

I try to localize my iOS app. Unfortunately I run into trouble with the localization. My problem is by adding the additional language, not all strings are listed in the main.strings file for the additional language. I have an scroll view and an label in my ViewController. The scroll view itself also has many label. Wenn I go into the main.string file, I miss the separat label as well as the first label in the scroll view.
Because the controller is the second view controller working as a description view, I've not added IBOutlets to the label. Just use them as text.
Does anyone know how to add these two label to the main.string file or maybe just give me a hint what I can check to see what's maybe wrong?
Thanks in advance

Ok, after two additional days I've found the reason why it was not working. At all I hope my question was not to silly and all member just thought RTFM.
I've solved my following problems:
1) How can I add additional Label-Text to the Localization file "main.strings" and
2) By adding an Language not all text are entered by Xcode to the main.stings file.
1)
In the document block from the identity inspector is a filed called Object ID. This is the Xcode generated reference to the Label (Text). Adding this to the specific language main.strings file with, close the line with an ";" and it works.
2)
Well, as far as I could investigate, localization just works with plain text (Attributes Inspector - Block Label). It does not work with attributed text. Maybe I did something wrong, but changing to "Plain" and problem was solved.
Thanks for all who spend some time to read my question.

Related

MKMapView Legal label shows as <unlocalized>

I've added an MKMapView as a subview on one of my ViewControllers in an XIB. The map works alright in terms of showing directions. But the Legal text on the map (bottom left) shows as <unlocalized> instead of having a text saying Legal in whatever language is selected (or even English).
How do I fix this? Thanks.
Note: My app supports 6 languages if it makes a difference (but none of the XIBs are localized)
I couldn`t reproduce this but it seems like an issue in the localization file. This guy has a similar problem and resolved it by removing localization files (and creating new I think).
Of course, you can always set directly your localized string to Legal MKAttributionLabel, by getting it from MKMapView subviews, and using setValue(_:forKey:) with _innerText and _strokeText keys. But notice that this is private API :)
I can think of 2 possible solution but didn't. One is to check which subview of all your MKMapView's subviews for that specific label and add move it out of the window or scale it down to 0. The other one would be similar but by subclassing you MKMapView and try to hide this label in layoutSubviews method.

UILabel Font Size Does Not Change in XIB while Color Does

This question seems simple, but this problem turned me crazy after days since none of the answers could solve my problem so far. I will be glad if someone can help me to figure it out.
So, I have a .xib file where I created a subview (called StaticDetailVerticalView) and I have also another .xib file for the whole page's view (called TripDetailView), and lastly, this TripDetailView is being used inside of a controller (called TripDetailViewController). My font problem occurs in StaticDetailVerticalView.
First, I was trying to set the fonts with an outlet from .xib with the methods [self.label setFont:[UIFont systemFontOfSize:20.0] and self.label.font = [self.label.font fontWithSize:20.0]. Then secondly, I tried setting from the TripDetailView by creating a IBInspectable fontSize inside StaticDetailVerticalView with direct setting from TripDetailView.xib file.
Also, when I try to change the color or the text by calling the methods exact same places with font changes, everything changes accordingly but the font size.
I hope there will be an answer to be accepted :) Joking aside, I really stuck in here.
Please ask me for further details, or any files that I can share for you if you need one. I am not adding the codes or screenshots since I believe this is not a problem by code based but something that I am missing about the outlets.
You can find the all three .xib files mentioned above here.
Thanks for all the helps and answers!
You can try to adjust the font size in your StaticDetailVerticalView.xib
Go to StaticDetailVerticalView.xib
Clic on the label you want to change the font's size
Clic on the button "Show the attributes inspector"
Then, you can change the font manually.

Xcode 8 Adding Layout Margins Crash

When I try to add layout margins to a label on a TableViewCell, using the right panel on Xcode, I try to add Explicit Margins (top, Left, Bottom, Right). But, as soon as I input a number value, or tap the arrow to change the value, Xcode crashes.
I've attached a photo to show the panel I am trying to add the layout margins in, and where it crashes.
Any ideas why it wont let me adjust the margins?
try to clear the constraints, connect/ reconnect the outlet and apply new constraints.
Had that problem. Its Xcode bug. Already fixed, so don't worry :)
I was facing similar problem.
The answer that I found and which I used in real project (but for UICollectionView) was to get the outlet of CollectionViewFlowLayout and to define the margins (line spacing and item spacing) by myself in code.
For example
collectionViewFlowLayout.minimumLineSpacing = getCollectionViewWidth() * 0.05
Where getCollectionViewWidth() is a function, that returns the size of collection view (for different screens it will be different) and 0.05 is just random coefficient.
I hope it may someway help you, you can feel free to ask anything else.
If you have crash when you add margins on any view in your storyboard you can try to get their outlets as well and to redefine their frames. It's kinda bad style, but if you won't figure out the problem its the only one I can recommend to you and which I used myself.
Also try to Clean project by clicking Product - Clean in you task bar when in X-Code.
Clear all the constraints and try from applying one by one. That way you can resolve this issue.
Please remove all the constraint applied and connected to the outlet. And Try to apply new constraints.
Some time we delete Outlet from you files .h or .m or swift file which was connected to view in Storyboard or xibs at that time this problem occurs.
Clearing all constraints is the way to go. Look around every nook and cranny and right click every little thing in both your Main.storyboard and the ViewControllerScene menu to its immediate left. If you can get the formatting back to its most base level your constraints will work fine!
Clear all the constraints and try from applying one by one.and take .xib file and connecte with Table view Cell
Xcode stores some user state information inside the Xcode project file, which is really a folder. That state information might have become corrupted. You can normally throw away everything inside your .xcodeproj folder except the project.pbxproj file. This might fix your problem.
Open up the folder containing your .xcodeproj file. Right-click the .xcodeproj file and choose Show Package Contents. Then throw away everything except the project.pbxproj file.
If you know what an Xcode workspace is, and you're actually making use of it, you might not have a project.xcworkspace file to throw away, or you might not want to throw it away. But if you don't know what an Xcode workspace is, then you're not using it so you can just throw away project.xcworkspace. Xcode will recreate it automatically.
see This Link

UITextView attributes inspector not showing full set of attributes

I have two Macs, both with the latest OS and Xcode versions. We're developing for iOS7.
On one Mac, everything seems OK. On the other, when I drop a UITextField onto a View Controller scene, the attributes inspector shows only a small subset of the attributes available.
I would expect to see something similar to the UITextView attributes but instead I see only this:
Have I done something wrong here or is this a bug? I seem to remember having edited attributes on a UITextField that I added earlier to another scene (font, text size, etc) but these are not available now.
I made a stupid mistake and I guess that someone else could do the same. I must have inadvertently clicked on the "Text Field" label at the top of the attributes panel and then scrolled up, missing it completely.
Doh!

How to write multiple lines in a label

I have a XIB file of type View XIB. In it I have a View controller, and in the View controller I have a label.
I have long text that I want to break, but it doesn't - it gets truncated.
I tried this solution - I did it in the attribute window - but it doesn't help.
You could use a TextView and disable the Editable and User Interaction Enabled options in IB.
use this
myLabel.lineBreakMode = UILineBreakModeWordWrap;
if you are worried about backwards compatibility use this because the comand i mentioned before was introduced in iOS 6.0
myLabel.numberOfLines = 0;
I have been running into a similar problem. I started out with a label, but wanted multi-lines and a UITextView worked great for this, at first. Because I am using a third party library (MBProgressHUD) to handle stuff like progress messages and what not, I had thread problems when trying to update a UITextView and show the progress message at the same time.
So I went back to UILabel which actually didn't have thread problems. I found a property to allow a specific number of lines of my choosing, and had to create the label big enough to display those lines. The downfall to this approach is that I don't get the context menus like Copy, Paste, etc. but more importantly I'm not running into thread problems. I can always embed this into a UIScrollView in the future if I so choose.
You could check out my category for UILabel on GitHub. https://gist.github.com/1005520
This lets you resize the height of the label to accommodate the content.
From the Attiribute inspector, choose LineBreaks->Word Wrap option when you have selected the lablel. Also increase the number of lines Label->Lines.
Try Following steps to solve issue :
Drag out a UITextView.
Double-click it to edit text, place cursor where you want the
paragraph break.
Option-Enter a couple of times to create a blank line & paragraph.

Resources