ios system Share and settings buttons - ios5

I have a task to clone an application of... I can't change the client mind, pls do not suggest it.
I can't found where is hidden in iOS this 2 buttons. I think it is coming from iOS, not just a The buttons looks like: and .
I am searching a code part, something like this:
refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:#selector(doStuff)];
but can't found a button share at:
typedef NS_ENUM(NSInteger, UIBarButtonSystemItem) {
UIBarButtonSystemItemDone,
UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
#if __IPHONE_3_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
UIBarButtonSystemItemUndo,
UIBarButtonSystemItemRedo,
#endif
#if __IPHONE_4_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
UIBarButtonSystemItemPageCurl,
#endif
};
in
UIBarButtonItem.h
Any help would be appreciated where to look at.
Need to support iOS 5.0
Edit: can't accept the answer with UIBarButtonSystemItemAction, because it looks like:
As you can see, it is not the "clone" of original, bar far away, because it is missing the description ( text under icon), checked the UITabBarSystemItem, since those has text under icon, but nothing match the 2x images:
typedef NS_ENUM(NSInteger, UITabBarSystemItem) {
UITabBarSystemItemMore,
UITabBarSystemItemFavorites,
UITabBarSystemItemFeatured,
UITabBarSystemItemTopRated,
UITabBarSystemItemRecents,
UITabBarSystemItemContacts,
UITabBarSystemItemHistory,
UITabBarSystemItemBookmarks,
UITabBarSystemItemSearch,
UITabBarSystemItemDownloads,
UITabBarSystemItemMostRecent,
UITabBarSystemItemMostViewed,
};
It seems need to search a custom library and get those 2 icons for or make 2x custom buttons with those images.

UIBarButtonSystemItemAction is what you are looking for the Share.
The settings icon doesn't exist as a system icon so you have to use a custom button with an image.
Here is an example on how to create a Bar Button with a custom image
EDIT:
As long as the share button is not exactly the same with what you want, add two custom buttons if you want the icons to look exactly as the native ones.
Kind reminder: Apple doesn't like it when developers immitating their custom controls when they aren't using the defaults.

Related

How to switch skins (or design themes) in iOS app?

I'd like to make my iPhone app to be able to switch between skins (or design theme, or look and feel, such as wooden, metal, earth color, men's, girls, etc...).
I'll prepare some sets of skins that contains images for buttons and backgrounds, sounds, and text color, and let the user decide which set of skin they want to use by the application settings.
What is the best practice to implement this?
The conditions are:
I'd like to use Interface Builder
I need to support iOS 3.1.3 and later
I want to make the sets of skins downloadable from the internet (I can't bundle all the skins in the app, as one set of skin requires lots of images and the app file size could become huge if I do so... I also don't want to hardcode any information about specific skins.)
If a custom skin does not contain one or some elements, (such as an image or sound file), I want it to use the missing element from the default set of skin.
I don't want to create Nib files for each skin. The Nib file for one screen should be the only one in the main bundle for easier maintenance.
I'm thinking about making a superclass of all the UIViewControllers in my app and override the part that it loads Nib file, and instead of loading from the main bundle, load the resources from the skin that is saved in the Document directory... but I don't know how to do it... The default behavior of the Nib-loading methods always loads resources from the main bundle and the information about resource file names are lost after reading... :(
Thanks in advance for your help.
Am not sure about best practice .. But, if your app is not big enough, then a well structured plist is your friend.
Initially, you could choose: Metal Theme. The following should hold:
You either have a Singleton ThemeManager, or just stick an NSDictionary to one of your Singletons if appropriate.
The point behind the ThemeManager is the mapping between the asset and the theme..
Some sample code (written directly on SOF .. Don't mind Syntax mistakes):
#define kThemeMap(__x__) [[ThemeManager sharedManager] assetForCurrentTheme:__x__]
...
-(void)doUselessStuff {
UIImage* backgroundImage = [UIImage imageNamed:kThemeMap(#"FirstViewBG")];
...
}
//in the ThemeManager:
//returns the appropriate name of the asset based on current theme
-(NSString*)assetForCurrentTheme:(NSString*)asset {
//_currentTheme is an NSDictionary initialized from a plist. Plist can be downloaded, too.
NSString* newAsset = [_currentTheme objectForKey:asset];
if(newAsset == nil) {
newAsset = [_defaultTheme objectForKey:asset];
}
return asset;
}
//Let us assume the user selects Metal Theme somewhere .. Still coding ThemeManager:
-(void)selectedNewTheme:(NSString*)newTheme {
//First, get the full path of the resource .. Either The main bundle, or documents directory or elsewhere..
NSString* fullPath = ...;
self.currentTheme = [NSDictionary dictionaryWithContentsOfFile:fullPath];
}
The plist files are just a dictionary with string to string mapping... something like this:
//Default.plist
#"FirstViewBG" : #"FirstViewBG_Default.png"
#"SecondViewBG" : #"SecondViewBG_Default.png"
#"WinSound" : #"WinSound_Default.aiff"
//Metal.plist
#"FirstViewBG" : #"FirstViewBG_Metal.png"
#"SecondViewBG" : #"SecondViewBG_Metal.png"
#"WinSound" : #"WinSound_Metal.aiff"
Alternatively, you can just save the postfix, if that is good enough for you.. But, it will require string manipulation, by slicing the extension -> adding the postfix -> adding the extension ..
Or maybe make it a prefix?
You can category on UIImage with the methored imageNamed:, use the custom imageNamed: instead of the default one.
In the custom methord, selected the image by theme.

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.

Translating text on buttons when using mfmailcomposeviewcontroller

How is it possible to change the title of the UIBarButtonItem's when using mfmailcomposeviewcontroller? I don't want the text "cancel"/"send" and I also do not need the save/delete draft option which prompt the user when he/she taps "cancel".
You can't. MFMailComposeViewController is not customizable.
You can change the Development Region in your Info.plist so that your system buttons will be translated, or add translations in your app and the system buttons will be translated to the user's selected language.
Note: This is probably a duplicate with this question
Thats because you have set it with a system item "style" UIBarButtonSystemItem.
You have these to use, or use a custom one:
UIBarButtonSystemItemDone,
UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
UIBarButtonSystemItemUndo, // iOS 3.0 and later
UIBarButtonSystemItemRedo, // iOS 3.0 and later
UIBarButtonSystemItemPageCurl, // iOS 4.0 and later
Oh i did not see the "Translating" from the title..

UIBarButtonSystemItem enum - Missing Icons?

I posted a question about mimicking the interface of the Maps application and have just come across another area where i'm unsure about the UIToolbar and UIBarButtonItem's.
In the Maps application, there are two buttons which don't seem to have any constant defined in the UIBarButtonItem documentation
At the bottom left of the app is the "location" icon and when clicking "directions" there is another "switch route" icon, neither of which are defined in the UIBarButtonItem.h
I'm guessing that these haven't been added to iOS 4 yet? Does this mean that the only way to include such buttons/images is to use the initWithImage:style:target:action: method when creating a UIBarButtonItem?
This isn't a problem, although finding similar images would be pain, I just want to make sure i'm, not reinventing the wheel when trying to include such elements.
Also, I note that whilst all the other UI elements can be styled in terms of color, the PageCurl button item doesn't seem to want to change at all. Ie: I can make all of the other toolbar buttons a different color to the default but the page curl refuses to change. Perhaps i'm missing something simple here?
Thanks for reading!
Correct, from the iOS documentation here are the only system icons available by default. You can safely assume that nothing outside of this list exists and you have to use your own image for it if you want something different:
typedef enum {
UIBarButtonSystemItemDone,
UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
UIBarButtonSystemItemUndo, // iOS 3.0 and later
UIBarButtonSystemItemRedo, // iOS 3.0 and later
UIBarButtonSystemItemPageCurl, // iOS 4.0 and later
} UIBarButtonSystemItem;

Using standard refresh button

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.