How to get localized timer label like UIDatePickerModeCountDownTimer? - objective-c

I want to get localized timer labels on my developing application.
For example, "hour,hours" and "min" on en_US, "時間" and "分" on ja_JP, "ora,ore" and "min" on it_IT etc.
UIDatePickerCountDownTimer mode can display them, but there seems no method to access.
I studied NSDateFormatter,NSLocale,UIDatePicker,etc, but I couldn't find the solution.
Please help me...

The text of the "hour" and "min" labels on UIDatePicker is not accessible to developers. If you want to use that text in your own app in a different context, you'll have to provide it yourself.
Of course, if you feel like this is something the frameworks should provide, please file a bug requesting this enhancement.

Related

ChartJS ignores 'chartOptions'

I can't find out how to set the "chartOptions", neither with the help of the documentation (https://vue-chartjs.org/), nor other tools.
For this I built a simple sandbox environment on codesandbox.io, so you can have a closer look.
There you can find two bar charts in the folder "components". Both have a different approach and both ignore e.g. the "min" and "max" value when scaling the chart. Just like the chart title is ignored, too. In the meantime I don't know what I can or should do. In the meantime I have tried everything possible and I just can't find a solution.
I need to define the options externally, or at least be able to override them before rendering. The second option would be even much better!
I would be very happy if someone could help me.
https://codesandbox.io/s/vuejs-3-chartjs-zz5194?file=/src/App.vue

Mapkit Searchbar Autocomplete Ios8

I'm trying to implement an Autocomplete on a search bar on a map using Mapkit. I found this :
https://github.com/chenyuan/SPGooglePlacesAutocomplete
Works and is totally perfect except that it uses UISearchDisplayViewController which has been deprecated in ios8 and replaced by UISearchViewController. Is there a way around it or a simpler way than the one mentioned above?
Thanks in Advance
Please try this new repo: https://github.com/hkellaway/HNKGooglePlacesAutocomplete, which is being actively maintained.
Apple provides a full autocomplete for the entire English language (and others) but if you want to implement your own autocomplete it's not too difficult, you simply need the range of words or phrases that you want to suggest and a way of ranking them in order of frequency used.
I've implemented a simple autocomplete in one of my projects that centers around a PredictionString class and an AutopredictCoordinator class.
The PredictionString has a NSString property and a float property which relates to the strings frequency of use by the user. The AutopredictCoordinator then holds an array of prediction strings and responds to requests for the most likely completion of any given string.

UILables, Text Flow and Layouts

Consider the following, I have paragraph data being sent to a view which needs to be placed over a background image, which has at the top and the bottom, fixed elements (fig1)
Fig1.
My thought was to split this into 4 labels (Fig1.example2) my question here is how I can get the text to flow through labels 1 - 4 given that label 1,2 & 3 ar of fixed height. I assumed here that label 3 should be populated prior to 4 hence the layout in the attached diagram.
Can someone suggest the best way of doing this with maybe an example?
Thanks
Wish I could help more, but I think I can at least point you in the right direction.
First, your idea seems very possible, but would involve lots of calculations of text size that would be ugly and might not produce ideal results. The way I see it working is a binary search of testing portions of your string with sizeWithFont: until you can get the best guess for what the label will fit into that size and still look "right". Then you have to actually break up the string and track it in pieces... just seems wrong.
In iOS 6 (unfortunately doesn't apply to you right now but I'll post it as a potential benefit to others), you could probably use one UILabel and an NSAttributed string. There would be a couple of options to go with here, (I haven't done it so I'm not sure which would be the best) but it seems that if you could format the page with html, you can initialize the attributed string that way.
From the docs:
You can create an attributed string from HTML data using the initialization methods initWithHTML:documentAttributes: and initWithHTML:baseURL:documentAttributes:. The methods return text attributes defined by the HTML as the attributes of the string. They return document-level attributes defined by the HTML, such as paper and margin sizes, by reference to an NSDictionary object, as described in “RTF Files and Attributed Strings.” The methods translate HTML as well as possible into structures of the Cocoa text system, but the Application Kit does not provide complete, true rendering of arbitrary HTML.
An alternative here would be to just use the available attributes, setting line indents and such according to the image size. I haven't worked with attributed strings at this level, so I the best reference would be the developer videos and the programming guide for NSAttributedString. https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/AttributedStrings/AttributedStrings.html#//apple_ref/doc/uid/10000036-BBCCGDBG
For lesser versions of iOS, you'd probably be better off becoming familiar with CoreText. In the end you'll be rewarded with a better looking result, reusability/flexibility, the list goes on. For that, I would start with the CoreText programming guide: https://developer.apple.com/library/mac/#documentation/StringsTextFonts/Conceptual/CoreText_Programming/Introduction/Introduction.html
Maybe someone else can provide some sample code, but I think just looking through the docs will give you less of a headache than trying to calculate 4 labels like that.
EDIT:
I changed the link for CoreText
You have to go with CoreText: create your AttributedString and a CTFramesetter with it.
Then you can get a CTFrame for each of your textboxes and draw it in your graphics context.
https://developer.apple.com/library/mac/#documentation/Carbon/Reference/CTFramesetterRef/Reference/reference.html#//apple_ref/doc/uid/TP40005105
You can also use a UIWebView

Multi language localization storyboard support issue

I have an issue with my project storyboard. I have added two localizations more to storyboard, so now I have three storyboards: spanish, english and basque. All of them depending from the main one:
Now I have the issue that I have to update all changes manually to all to storyboards, because if I do changes to MainStoryboard, the others are not updated with this changes.
How can I modify all storyboards at the same time?
Thanks
Here is a really great tutorial for automating changes from one storyboard localization to all the others:
http://danielsaidi.wordpress.com/2012/08/20/localization-in-ios/
http://www.youtube.com/watch?v=cF1Rf02QvZQ
From what I gather, the solution involves adding a python script to the end of the build that syncs the storyboards and generates string files.
Go to the links for a more detailed solution. They said it better than I can.
You could either take out all the strings from Storyboard and put them in localized set of strings. Then you would have to do everything in your code like this:
self.label = NSLocalizedString("LABEL_STRING", nil);
or you could open the Storyboard as an XML file and do it there maybe a little faster. But other than that, no it is not doable, bcs the Storyboard localization serves you for polishing your localization. Say you have a screen called "HOME" and then (using google translate), you have "HASIERA" in basque. The problem here is, that in basque it's longer, so you need to adjust the GUI elements so it fits the screen perfectly. What could happen is that the string would be cut off, which we don't want to happen. That's why you need to do Storyboard localization step by step. If you don't need it, use strings file instead...

Simulate "Slide to Unlock" in MobileSubstrate

There is a way to simulate the Slide To Unlock in the lockscreen? I've been looked for this in SBAwayController, but without any results :( Have anyone an idea?
I believe (if I understand your question correctly) you want to have the lockbar "unlock itself". For something like that you want to look into SBAwayView, not SBAwayController. In that class there are different methods that interact with the different lockbars. You will want to specifically look at the SBAwayLockBar which is a sublcass of TPBottomLockBar (defined in <TelephonyUI/TPBottomLockBar.h>)
You will have to poke around in the headers and see if there is any way to access the lockbar's Knob position.
Hope that helped at least a bit.