Ignoring the users default language/locale and set an own? - iphone

is it possible to set a locale for the app with no regard to the users language? My motivation is that I don't want the automatically translated labels of some buttons.
Sincerely,
Heinrich

Create the buttons with UIBarButton's
- (id)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action
And define your own title / style to create your buttons.

If you don't want certain buttons to appear in the user's language, then do not translate the button into that language.

Related

UIActionSheet with Images like menu

How I can create something like this:
Because UIActionSheet has only text
- (NSInteger)addButtonWithTitle:(NSString *)title;
You need to use a UIActivityViewController
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIActivityViewController_Class/Reference/Reference.html
If you require more than what it provides, you'll need to create your own UIView

Remove Year from date picker in iPhone/iOS app

I want to remove year from iOS date picker. Need to use in iPhone app.
This is down to the users phone localization settings... You'll need to create some sort of custom UIPicker if you want to make it the same for all.
Quick and easy way, create your UIPickerView with just two components.
You can't use the UIDatePicker because The UIDatePicker only supports the following modes
typedef enum {
UIDatePickerModeTime,
UIDatePickerModeDate,
UIDatePickerModeDateAndTime,
UIDatePickerModeCountDownTimer
} UIDatePickerMode;
Create a view and controller that implement the UIPickerViewDelegate and create your own - you may find a little more detail here
Fixed labels in the selection bar of a UIPickerView

iPhone Checkboxes à la Mail

After reading the iPhone Human Interface Guidelines, I notice there's little mention of checkboxes in the style that one may encounter them on the desktop or web.
Checkboxes are generally handled by UISwitchs on the iPhone, but for an app I'm presently working on, they're really not the right control. Instead, the control you'll see in Mail is a much better fit:
Actual mail blanked out. Obviously.
How would I go about using these checkbox controls in my app? Are they standard, or will I need to imitate them with a custom control?
Cheers friends.
You'll need to create a custom control. It won't be difficult since UIControl already has 'selected', 'highlighted' and 'state' properties at your disposal. You'll just need to draw and toggle appropriately.
Don't subclass UIControl. What you want is a UIButton of "custom" type. Load it with your "unlit" image in IB (or programmatically in -viewDidLoad--you can set it appropriate to its data there too, if you came here with that property already "checked").
Point its touchUpInside event at a method called -(void)toggleCheckBox, and in that method, toggle whatever setting you're toggling (probably a BOOL property of the objects you're listing), and toggle the "lit/unlit" status of the button image by using its -setImage: forState: method. Use the control state UIControlStateNormal.
I do something similar where I let people poke a button to toggle the "favorite" status of the thing ("thisEvent"--a member of an array of local cultural/arts events) they're looking at:
- (IBAction)toggleFavorite {
if (self.thisEvent.isFavorite == YES) {
self.thisEvent.isFavorite = NO;
[self.favoriteButton setImage:[UIImage imageNamed:#"notFavorite.png"] forState:UIControlStateNormal];
}
else {
self.thisEvent.isFavorite = YES;
[self.favoriteButton setImage:[UIImage imageNamed:#"isFavorite.png"] forState:UIControlStateNormal];
}
}
I'm pretty certain there is no standard way to do this. However it's fairly simple to achieve, all you need is two images, one for each state. I would probably do something simple like subclass UIImageView and add a setState:(BOOL)theState method, which would then simply select the relevant image.
I'd rather subclass UITableViewCell then UIImageView. UITableViewCell allready comes with selected/unselected states and handlers for editmodes etc.
As said before, you'll need to subclass UIControl. The actual process was discussed here w little while ago.
I also found a description of another way to do this using the same image/method that the Mail app uses:
http://networkpx.blogspot.com/2009/07/multiple-row-selection-with-uitableview.html
but as this implements undocumented features of the iOS SDK, it may not be best for apps intended for the official App Store.

iphone - Get dynamically created UITextField by tag

I add a UITextField to a table cell dynamically in my app. I'd like to implement a "backgroundClick" method to dismiss the keyboard if the user presses outside the textfield (and outside the keyboard) but I'm unsure how to get a handle on the active keyboard in the backgroundClick method as the dynamic UITextField does not have a defined property to use.
All I know is that it is a UITextField with a particular tag. Is there some way to get a hold of it in code?
Cheers.
UITextField* field = (UITextField *) [myTableCell viewWithTag: myTag];
[field resignFirstResponder];
Is that what you are seeking?
Edit to reflect comments:
Based on your comment, it's not. So, you probably want to read this other SO question.
If you have a reference to the UITextField, then you can send resignFirstResponder. That will dismiss the keyboard.

how to get input from UIAlertView?

I want take player name as input by using UIAlertView. Is it possible to add textField on the UIAlertView?
Since iOS 5, UIAlertView provides this: change the alertViewStyle property to one of the following:
UIAlertViewStylePlainTextInput (1 text field)
UIAlertViewStyleSecureTextInput (1 password field)
UIAlertViewStyleLoginAndPasswordInput (both a text field and password field)
Then use textFieldAtIndex: to get the text field you want. This way, you can even use the alertViewShouldEnableFirstOtherButton: delegate method to enable the button.
Yes, it's definitely possible, and it isn't a hack. You would need to subclass UIAlertView and place controls into it. Since it's a subclass, it will retain the same look & feel, etc.
For full details, see this tutorial by Jeff LaMarche (co-author of Beginning iPhone Development, from Apress).
Yes, but not without some hacking, see this previous question.
You'd have to directly manipulate the UIAlertView's subviews and add a UITextField and then resize the UIAlertView's frame. You're better off creating your own view.