Using standard refresh button - iphone

I'm trying to display a small refresh button using UIButton in a standard UIView using the refresh icon built into UIKit. If I use an UIBarButtonItem it can be created as a refresh button, but I've had no luck in using this icon in other places.
So far I've tried to "steal" the refresh image of a UIBarButtonItem using the code below, but the image returned is nil:
UIBarButtonItem *temp = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:nil action:nil];
self.refreshButton.imageView.image = temp.image;
[temp release];
Any suggestions, or do I have to provide a refresh image myself?

Here's the png, straight from the OS:

You'll have to either make one yourself, hire a designer, or find a free one somewhere that you can use. The Toolbar buttons can only be used inside of a toolbar.

Glyphish has a free set of icons, including a "refresh" icon, which you can use if you agree to the Creative Commons Attribution license terms.

I don't know that Apple would allow you to use their UI images in a way they deem inappropriate, but you could always try a screenshot and store the image in your project yourself. You can run a sample in the simulator to get an easy screenshot on your development machine.
Failing that, I've found a ton of excellent icons sets at http://icons.mysitemyway.com/

IN OS X, you can get that icon with NSImageNameRefreshTemplate, check the doc "System-Provided Icons". But for iOS, system provided icons are not exposed to our developers I think.

Related

Can I use the system Touch Bar icons in my app?

I am trying to add a "New" button and a "Search" button for my app onto the Touch Bar. In system apps, these are a plus sign and a magnifying glass, respectively. Is there a way to use these system icons on my touch bar buttons, such as in UIBarButtonItems? If not, how can I set a touch bar button's content to be a magnifying glass or plus sign? I am using Swift. Thanks.
Apple provides many system icons that you can use in your app.
The Human Interface Guidelines has a nice visual reference of all of the icons available here. These can be referenced in your app by using the associated NSImage.Name constant (also described in the HIG).
As an example, the new and search images can be gotten using:
let addImage = NSImage(named: .touchBarAddTemplate)
let searchImage = NSImage(named: .touchBarSearchTemplate)
Maybe you could find those icons in the system files, copy them and use them in your application, but I would not recommend it. They are Apple's intellectual property and you are not allowed to use them for public projects.
You should search on sites like flaticon.com for similar artworks or create them yourself.

which multi-selection can be implemented in iphone (Registration page)

I have multi-selection dialog(drop-down) in Android where user selects all options applicable to him in registration page.What can be used in Iphone for the same purpose ?
And selecting a few options will unhide few textfields which is mandatory to fill.
Let me know what can be my approach.Please share any open source code links.
Thanks in advance.
No, there is no such thing within the iOS SDK and that is for a good reason - those elements are just not pretty, funky and usable well enough when acting on a touch display.
Consider using UIPickerView or UISegmentedControl instead. Maybe also have a look at Action Sheet.

dynamic button text iphone

If you want to make a multilingual button on a native iPhone app, where it can be one language by default, but based on your settings, show different text on the same button, how would you go about it?
Is it also possible to style (e.g. with text-shadows and custom fonts) the text on the button?
I'm not an iOS developer, but I'm attempting to provide designs for an iOS developer and don't understand the limitations (yet) when going from CSS3 to iOS UI elements.
So far, iOS development appears to be like creating image-maps where none of the CSS logic is applicable from web development and almost all UI elements appear to need all states as flattened images. I thought the controls were more dynamic but haven't found the right terminology for results from google to be very forthcoming on the topic.
U can use NSLocalizedString for multilingual text on button.
Configuring Button Title
titleLabel property
reversesTitleShadowWhenHighlighted property
– setTitle:forState:
– setTitleColor:forState:
– setTitleShadowColor:forState:
– titleColorForState:
– titleForState:
– titleShadowColorForState:
Also set Custom font like this:
yourButton.titleLabel.font = [UIFont fontWithName:#"Courier" size:22.0];
if u want to add gradient to button then u will have to use CALayer like this:
yourButton.layer = //any modification in button's layer here
For more refer UIButton class reference

iPhone action button image file available anywhere?

I'm working on an app and want to use the image from the action type toolbar button (the one with the arrow coming from the box that we often use for share etc) in a custom button. Is there some way I can get hold of the .png for it?
Thanks
There is the open source UIKit artwork extractor project available at Github: https://github.com/0xced/UIKit-Artwork-Extractor
There's a mockup toolkit available for iOS SDK at http://blog.metaspark.com/2009/02/fireworks-toolkit-for-creating-iphone-ui-mockups/
Check the fourth image on right most column. I hope it contains the image you want.
You can download the mockup toolkit and open up with fireworks or photoshop to extract images from there. If you don't have these adobe softwares then the open source software GIMP is your good friend to extract the image.
There really is no need to duplicate the image content since its already in the framework.
Have a look at this code:
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:#selector(onActionButtonClicked:)];
The relevant portion being the initWithBarButtonSystemItem initialization method.
This question may also be more useful in answering this question than the selected answer.

UIBarButtonSystemItem localizable

How can I make UIBarbuttonItem localizable?
My implementation:
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:#selector(cancel)];
Originally I thought that it is automatic, because it looks easy to make it like this, but looks like not.
EDIT1: Official Apple dox says that cancel, done, edit, save buttons are localized, but not sure how to make it.
Alright, I think I know what's going on.
UIKit decides in which language to display strings, based on the value of [[NSBundle mainBundle] preferredLocalizations]. The idea behind this is to use translated resources whenever possible, falling back to English otherwise. For example, if you don't provide the translation of your app in Finnish and Finnish is selected in Settings->General->International->Language, your app will be in English. It may be a bit more complicated (UIKit may go through all the list of languages in the order displayed in Settings.app, trying to find the first language your app has translations for), but the point stands.
The above may be too obvious to miss a crucial nuance. The language determined by the above algorithm is used for the app's whole UI. For example, if the app bundle doesn't contain sk.lproj, nothing will be displayed in Slovak. In fact, it does make sense because otherwise some parts of UI would be in Slovak, other parts, in English.
Open the compiled app's bundle to see which *.lproj folders are there. The same set, sorted according to user preferences, will be returned by [[NSBundle mainBundle] preferredLocalizations]. All localizable strings, including system bar button items, will be displayed in one of those languages. If you don't support, for example, Russian, the whole UI will appear in another language, even if Russian is selected in Settings.app.
If this is the case with your app indeed, there are two right things and one wrong thing to do:
right: provide Slovak translation for each and every string displayed in your app, translate any text-containing nibs to Slovak too;
right: ignore Slovak altogether if you cannot (or don't need to) support it;
wrong: select any strings file or any nib, open Xcode's inspector, click "Add Localization…" (if the button is disabled, first click "Make File Localizable"), type "sk", click "Add" and build the project. This will make UIKit think your app is translated to Slovak, and system bar button items will automatically appear in Slovak when it's selected in Settings.app.
If you see a different behavior, there may be something wrong with the project/build/built app. For example, I noticed that when you make a file localized, its non-localized copy doesn't get deleted from the previously built app bundle.
Bump, but I think Vanya’s problem might be the “Localization native development region”/CFBundleDevelopmentRegion entry in Info.plist. If this is set to English and no localizations are explicitly made available as Costique explains, all system strings will be non-localized. But, set it to sk and - violà.
Not sure I understand your question correctly, but standard (system) bar button items are localized and thus automatically appear in the user-selected language. There are notable exceptions like UISwitch showing 0/1 instead of ON/OFF. What language are you having problems with?
That said, you can always use custom bar button items in place of system ones and provide necessary translations yourself. It's just overkill in most cases.
My implementation in Swift:
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(doneButtonTapped(button:)))
This uses the system default language for "Done" text.