In my application, i have some leftBarbutton of the navigation bar set to " retour" and some others set to "back" i would like to set all my buttons to "retour", how to do this please ? i have spend many hours to dos this.
thanks
I reckon you want to change the language, rather than the button description itsself.
In oder to change the language have a look into the (appname)-Info.plist.
There is an Attribute: Localization native development region.
Change it accordingly to, i guess in your case France if. am not horribl wrong.
Cheers,
Sebastian
UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
[btn setTitle:#"retour" forState:UIControlStateNormal];
btn.frame=CGRectMake(3, 2, 53, 30);
UIBarButtonItem *btnBack=[[UIBarButtonItem alloc] initWithCustomView:btn];
self.navigationItem.leftBarButtonItem=btnBack;
[btnBack release];
[btn release];
Related
Is it possible to make the navigationcontroller title a button? but without a button look to it. I want it to be just text that if you click on it a view/actionsheet pops up from the bottom
If so, can you show me programmatically how I would make it a button?
Thanks
You can set TitleView of navigationItem to set a button as title.
Here is what i tried and got it working:
UIButton*button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame=CGRectMake(0, 0, 30, 20);
[button setTitle:#"Testing" forState:UIControlStateNormal];
[button addTarget:self action:#selector(btnAction) forControlEvents:UIControlEventTouchUpInside];
[[self navigationItem] setTitleView:button];
But if you don't want it to look like a button, you have set the buttonWithType to custom and set its backGroundImage property.
in btnAction have your code to show the pop ups.
Please see the link below.
http://itunes.apple.com/app/id383298204?mt=8
There are screen shots of showpick application. In that there is a collect button which is some what impossible to implement under ui tab bar. Can someone help me to figure it out how they have implemented it? Is that an actual UITabBar?
Thank you
I figured out a workaround. I basically add a dummy controller for the middle entry of the UITabBarController. And in viewDidLoad I add a button to the UITabBar like so:
tabBarButton = [[UIButton alloc]initWithFrame:CGRectMake(125, -10, 70, 33)];
[tabBarButton setBackgroundImage:[UIImage imageNamed:#"state-inactive"]forState:tabBarButton];
[topbarButtonScan setBackgroundImage:[UIImage imageNamed:#"state-active"]forState:UIControlEventTouchDown];
[tabBarButton addTarget:self action:#selector(tabBarButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[[[self tabBarController]tabBar ] addSubview: tabBarButton];
I have a button in headerview of my tableview, its woking fine as well, but problem i am having is: When I want to hide that button on click of another button. How can I achieve this? I have already tried
[deletebutton removeFromSuperview];
where deleteButton is my buttons name.
Here is what I am doing
-(void)PutTableinEditMode{
DeleteButton=[UIButton buttonWithType:UIButtonTypeCustom];
DeleteButton.frame=CGRectMake(10,1, 65, 25);
[DeleteButton setTitle:#"Delete" forState:UIControlStateNormal];
DeleteButton.backgroundColor=[UIColor clearColor];
[DeleteButton addTarget:self action:#selector(DeleteMultipleToDos) forControlEvents:UIControlEventTouchUpInside];
[headerView addSubview:DeleteButton];
}
Then I m having another function as below from where i want to hide this DeleteButton
-(void)DoneEditing
{
DeleteButton.hidden=YES;
[DeleteButton removeFromSuperview];
}
deletebutton.hidden = YES
if any of those two solution (removeFromSuperview and hidden) do not work, then you certainly don't have the right reference to your button. I guess your using nib files to define your views ? Then be sure the member deleteButton is well "linked" to the actual button. (i.e. verify using debug that your deleteButton var is not null)
Can u try and change the Text of that button because i'm thinking your sending messages to nil objects.
I got the it working actually [DeleteButton removeFromSuperView] is working .. problem was that the first method PutTableinEditMode was being called from somewhere else also, so i simply took a bool variable and on basis of its value added and removed the delete button
:)
Thanks guys for helping though :)
Ifeel so stupid to make such a silly mistake :)
I have a UIBarButtonItem on a navigation bar. I'd like to make it arrow shaped. By that I mean I want it to be square except for a pointy side. Does anyone know how to do this?
Thanks!
I wrestled with several approaches on this one and finally figured it out using all the answers from several sources. There are a couple of tricks; this snippet will show it all (I was creating a custom rightNavButton, but you can adapt this easily for any UIBarButtonItem):
// Produces a nice "right arrow" style button that mirrors the back arrow
// automatically added by the navController
//
UIImage *buttonImage = [UIImage imageNamed:#"forwardButton.png"];
UIButton *forwardButton = [UIButton buttonWithType:UIButtonTypeCustom];
[forwardButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
[forwardButton setTitle:#"Meter" forState:UIControlStateNormal];
forwardButton.font = [UIFont boldSystemFontOfSize:12];
forwardButton.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
[forwardButton addTarget:self action:#selector(showMeter)
forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithCustomView:forwardButton];
Note: it turns out that if you try to set the target and action directly on the button item after assigning a custom view using a UIButton that it won't take - you have to set the target and action on the button itself - apparently the navBar uses the button provided verbatim.
This is the image I was using on the opaque black navBar (you can use anything, obviously): http://raretiger.com/images/forwardbutton.png
Make a custom background. See Creating a left-arrow button (like UINavigationBar's "back" style) on a UIToolbar for how.
You may -pushNavigationItem:animated: to make the built-in back button appear, although you cannot assign custom actions to it.
For undocumented methods, you may use
UIButton* backButton = [UIButton buttonWithType:101];
to create a back "button".
You could create an UIImageView or an UIButton with the required image then use:
[[UIBarButtonItem alloc] initWithCustomView: arrowButton];
Hope this helps.
continuing on #Plamen Dragozov's idea: i noticed if you leave the uibutton as is, it would trigger a picture adjustment when touched and that is quite the opposite what a normal navigation back button does. So what I did was to uncheck "highlighted adjusts Image" and it works like a charm.
hope this helps newbies like me.
More elegant solution:
UIBarButtonItem * backButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Title" style:UIBarButtonItemStylePlain target:self action:#selector(back:)];
[backButtonItem setBackgroundImage:[UIImage imageNamed:#"back.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
self.navigationItem.leftBarButtonItem = backButtonItem;
My problem was renaming the back button that appears on the pushed view controller. I found a dirty workaround and if you ignore the non-ideal animation problem, you'll get a back button with the title you want.
The trick is to change the title of the first VC in viewWillDisappear and re-set it of course in viewWillAppear
(Needless to say, by default, if there is no leftBarButtonItem set, UINavigationController will show a back button with the title of the VC that pushed the current VC)
In the VC where you push your current VC, do
-(void) viewWillDisappear:(BOOL) animated {
[super viewWillDisappear:animated];
self.title = #"Back";
}
-(void) viewWillAppear:(BOOL) animated {
[super viewWillAppear:animated];
self.title = #"Original Title";
}
Is there a way to get access to the up/down arrows used in the Mail app and implement them the same way?
No, there's no supported way to do it. I'd suggest you file a bug on Radar asking Apple to include more built-in artwork. In the mean time, you'll just have to draw your own.
Can you clarify your question?
The graphics for up/down are not easily accessible, though you can probably find a way to get them. For instance, see http://0xced.blogspot.com/2009/04/extract-uikit-artwork.html.
But if you're looking for the behavior, it's really quite simple. The arrows are on a momentary UISegmentedControl. Attach to valueChanged: to tell when the user taps on one of them, and use selectedSegmentIndex to tell which one they tapped.
Nowadays they are part of the sample code of IOS 4.1. Check the NavBar sample.
As Steven Fisher said, you can’t access the Apple graphic easily. But they are relatively easy to remake.
Given the images I had some trouble making this look right in iOS 7 where a UISegmentedControl will not work. This code did the trick however (added to viewDidLoad in the ViewController).
UIButton *upButton = [UIButton buttonWithType:UIButtonTypeCustom];
[upButton setImage:[upImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
forState:UIControlStateNormal];
upButton.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 6);
[upButton sizeToFit];
UIButton *downButton = [UIButton buttonWithType:UIButtonTypeCustom];
[downButton setImage:[downImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
forState:UIControlStateNormal];
downButton.contentEdgeInsets = UIEdgeInsetsMake(0, 6, 0, 0);
[downButton sizeToFit];
UIBarButtonItem *upButtonItem = [[UIBarButtonItem alloc] initWithCustomView:upButton];
UIBarButtonItem *downButtonItem = [[UIBarButtonItem alloc] initWithCustomView:downButton];
[upButton addTarget:self action:#selector(YOUR_UP_SELECTOR:) forControlEvents:UIControlEventTouchUpInside];
[downButton addTarget:self action:#selector(YOUR_DOWN_SELECTOR:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItems = #[downButtonItem, upButtonItem];